Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't run express server with sqlite3 #8771

Open
m860 opened this issue Apr 10, 2024 · 2 comments
Open

I can't run express server with sqlite3 #8771

m860 opened this issue Apr 10, 2024 · 2 comments

Comments

@m860
Copy link

m860 commented Apr 10, 2024

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/[email protected]/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/[email protected]/node_modules/bindings/bindings.js:126:9)
    at node_modules/.pnpm/[email protected]/node_modules/sqlite3/lib/sqlite3-binding.js (/Users/.../Documents/git/test/node_modules/.pnpm/[email protected]/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/[email protected]/node_modules/sqlite3/lib/sqlite3.js (/Users/.../Documents/git/test/node_modules/.pnpm/[email protected]/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

@GiladShoham
Copy link
Member

@zkochan do you have any idea?

@davidfirst
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants