teambit / bit

A build system for development of composable software.

Home Page:https://bit.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I can't run express server with sqlite3

m860 opened this issue Β· comments

commented

Description

I create a test project

mkdir test
cd test
bit init
bit create express-serve api
bit install sqlite3

and add sqlite3 test code

import express from 'express';
import { Api } from "./api.js";

// sqlite3 test code
import sqlite3 from "sqlite3"
const Sqlite3 = sqlite3.verbose();
const db = new Sqlite3.Database("fire");

export function run() {
  const app = express();
  const api = Api.from();
  const port = process.env.PORT || 3000;

  /**
   * learn more on the express docs:
   * https://expressjs.com/en/starter/hello-world.html
   */
  app.get('/', async (req, res) => {
    const greeting = await api.getHello();
    res.send(greeting);
  });

  const server = app.listen(port, () => {
    console.log(`πŸš€  Server ready at: http://localhost:${port}`);
  });

  return {
    port,
    // implement stop to support HMR.
    stop: async () => {
      server.closeAllConnections();
      server.close();
    }
  };
}

outpout

/Users/.../Documents/git/test/node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js:126
  err = new Error(
        ^


Error: Could not locate the bindings file. Tried:
 β†’ /Users/.../Documents/git/test/build/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/build/Debug/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/build/Release/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/out/Debug/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/Debug/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/out/Release/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/Release/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/build/default/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/compiled/20.11.1/darwin/x64/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/addon-build/release/install-root/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/addon-build/debug/install-root/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/addon-build/default/install-root/node_sqlite3.node
 β†’ /Users/.../Documents/git/test/lib/binding/node-v115-darwin-x64/node_sqlite3.node
    at bindings (/Users/.../Documents/git/test/node_modules/.pnpm/bindings@1.5.0/node_modules/bindings/bindings.js:126:9)
    at node_modules/.pnpm/sqlite3@5.1.7/node_modules/sqlite3/lib/sqlite3-binding.js (/Users/.../Documents/git/test/node_modules/.pnpm/sqlite3@5.1.7/node_modules/sqlite3/lib/sqlite3-binding.js:1:18)
    at __require (/Users/.../Documents/git/test/node_modules/.pnpm/file+my-scope+api/node_modules/@my-scope/api/dist/api.cjs:8:50)
    at node_modules/.pnpm/sqlite3@5.1.7/node_modules/sqlite3/lib/sqlite3.js (/Users/.../Documents/git/test/node_modules/.pnpm/sqlite3@5.1.7/node_modules/sqlite3/lib/sqlite3.js:2:17)
    at __require (/Users/.../Documents/git/test/node_modules/.pnpm/file+my-scope+api/node_modules/@my-scope/api/dist/api.cjs:8:50)
    at Object.<anonymous> (/Users/.../Documents/git/test/node_modules/.pnpm/file+my-scope+api/node_modules/@my-scope/api/dist/api.app-root.ts:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12) {
  tries: [
    '/Users/.../Documents/git/test/build/node_sqlite3.node',
    '/Users/.../Documents/git/test/build/Debug/node_sqlite3.node',
    '/Users/.../Documents/git/test/build/Release/node_sqlite3.node',
    '/Users/.../Documents/git/test/out/Debug/node_sqlite3.node',
    '/Users/.../Documents/git/test/Debug/node_sqlite3.node',
    '/Users/.../Documents/git/test/out/Release/node_sqlite3.node',
    '/Users/.../Documents/git/test/Release/node_sqlite3.node',
    '/Users/.../Documents/git/test/build/default/node_sqlite3.node',
    '/Users/.../Documents/git/test/compiled/20.11.1/darwin/x64/node_sqlite3.node',
    '/Users/.../Documents/git/test/addon-build/release/install-root/node_sqlite3.node',
    '/Users/.../Documents/git/test/addon-build/debug/install-root/node_sqlite3.node',
    '/Users/.../Documents/git/test/addon-build/default/install-root/node_sqlite3.node',
    '/Users/.../Documents/git/test/lib/binding/node-v115-darwin-x64/node_sqlite3.node'
  ]
}

Specifications

  • Bit version:v1.6.106
  • Node version:v18.20.1
  • npm / yarn version:10.5.0
  • Platform:macOS Monterey 12.5
  • Bit compiler (include version):
  • Bit tester (include version):

Context and additional information

@zkochan do you have any idea?

From a quick look, it looks like an issue with the sqlite3 installation.
Can you create a simple .js file in the same dir and start the sqlite3 db? just to make sure it works regardless of bit.