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

sqlite3 5.1.7 will not require or import on nodejs #4412

Closed
2 tasks done
woodbri opened this issue Jun 3, 2024 · 6 comments
Closed
2 tasks done

sqlite3 5.1.7 will not require or import on nodejs #4412

woodbri opened this issue Jun 3, 2024 · 6 comments

Comments

@woodbri
Copy link

woodbri commented Jun 3, 2024

Node.js Version

v21.7.2

NPM Version

10.5.0

Operating System

MINGW64_NT-10.0-19045 DESKTOP-MD7Q6H6 3.5.3.x86_64 2024-05-06 06:45 UTC x86_64 Msys

Subsystem

Other

Description

I can not get sqlite3 5.1.7 to import or require into a script. It throws a kill. I have tried multiple way of doing this with no success.

Minimal Reproduction

$ cat package.json
{
  "name": "test-sqlite3",
  "version": "0.1.0",
  "private": true,
  "scripts": {
  },
  "dependencies": {
    "sqlite3": "^5.1.7"
  }
}
$ cat test4
#!/usr/bin/env node

const sqlite3 = require( 'sqlite3' );

console.log('Connecting to DB');

sqlite3.verbose();
let db = new sqlite3.Database(':memory:', (err) => {
        if (err) {
                return console.error(err.message);
        }

        console.log('Connected to DB.');
});

console.log('Closing DB');

db.close((err) => {
        if (err) {
                return console.error(err.message);
        }
});

console.log('DB closed, Exiting');

Alternatively using "type": "module" in package.json

$ cat test2
#!/usr/bin/env node

import sqlite3 from 'sqlite3';

console.log('Connecting to DB');

sqlite3.verbose();
let db = new sqlite3.Database(':memory:', (err) => {
        if (err) {
                return console.error(err.message);
        }

        console.log('Connected to DB.');
});

console.log('Closing DB');

db.close((err) => {
        if (err) {
                return console.error(err.message);
        }
});

console.log('DB closed, Exiting');

Output

$ node inspect test2
< Debugger listening on ws://127.0.0.1:9229/6ac6169c-e11b-4540-834f-4424cb5ad943
< For help, see: https://nodejs.org/en/docs/inspector
<
connecting to 127.0.0.1:9229 ... ok
Break on start in test2:1
> 1 #!/usr/bin/env node
  2
  3 import sqlite3 from 'sqlite3';
debug> n
debug> There was an internal error in Node.js. Please report this bug.
read ECONNRESET
Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: kill EPERM
    at ChildProcess.kill (node:internal/child_process:512:26)
    at process.handleUnexpectedError (node:internal/debugger/inspect:360:42)
    at process.emit (node:events:531:35)
    at process.emit (node:domain:488:12)
    at process._fatalException (node:internal/process/execution:178:25)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.kill (node:internal/child_process:512:12)
    at process.handleUnexpectedError (node:internal/debugger/inspect:360:42)
    [... lines matching original stack trace ...]
    at process._fatalException (node:internal/process/execution:178:25) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'kill'
}

Node.js v21.7.2

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask
@RedYetiDev
Copy link
Member

Two notes:

  1. Please reformat your question to use proper styling
  2. This is an issue with what seems to be a third-party package, have you tried reaching out to them?

@RedYetiDev RedYetiDev added question needs more info issues that need more info from the author labels Jun 3, 2024
@woodbri
Copy link
Author

woodbri commented Jun 3, 2024

I've simplified the test case to:

npm install [email protected]
node -e 'require("sqlite3")'
node:internal/modules/cjs/loader:1464
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\msys64\home\woodbri\work\test-sqlite3\node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-
x64\node_sqlite3.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1464:18)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (C:\msys64\home\woodbri\work\test-sqlite3\node_modules\sqlite3\lib\sqlite3
-binding.js:4:17)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v21.7.2

I've also tried this with sqlite3 versions 5.1.5, 5.1.6, and 5.1.7 and get the same results.
Yes looked at the package site and see various similar problems and tried various work-a-rounds.

This is such a simple test and I find it hard to believe that no one can run sqlite3 in nodejs in msys2/mingw64 environment.

@woodbri
Copy link
Author

woodbri commented Jun 3, 2024

Same issue using --import=sqlite3

$ node --import=sqlite3
node:internal/modules/cjs/loader:1464
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\msys64\home\woodbri\work\test-sqlite3\node_modules\sqlite3\lib\binding\napi-v6-win32-unknown-
x64\node_sqlite3.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1464:18)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (C:\msys64\home\woodbri\work\test-sqlite3\node_modules\sqlite3\lib\sqlite3
-binding.js:4:17)
    at Module._compile (node:internal/modules/cjs/loader:1368:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
    at Module.load (node:internal/modules/cjs/loader:1205:32)
    at Module._load (node:internal/modules/cjs/loader:1021:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v21.7.2

@woodbri
Copy link
Author

woodbri commented Jun 3, 2024

@woodbri
Copy link
Author

woodbri commented Jun 4, 2024

I installed sqlite3 with

pacman -S mingw-w64-x86_64-sqlite3

and this seems to get rid is DLL loading error but is now goes back to the original error

$ node inspect -e 'require("sqlite3")'
< Debugger listening on ws://127.0.0.1:9229/45ec13d8-2c3d-445c-8f04-d7370eefbd82
< For help, see: https://nodejs.org/en/docs/inspector
<
connecting to 127.0.0.1:9229 ... ok
Break on start in [eval]:1
> 1 require("sqlite3")
debug> n
debug> There was an internal error in Node.js. Please report this bug.
read ECONNRESET
Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
node:events:497
      throw er; // Unhandled 'error' event
      ^

Error: kill EPERM
    at ChildProcess.kill (node:internal/child_process:512:26)
    at process.handleUnexpectedError (node:internal/debugger/inspect:360:42)
    at process.emit (node:events:531:35)
    at process.emit (node:domain:488:12)
    at process._fatalException (node:internal/process/execution:178:25)
Emitted 'error' event on ChildProcess instance at:
    at ChildProcess.kill (node:internal/child_process:512:12)
    at process.handleUnexpectedError (node:internal/debugger/inspect:360:42)
    [... lines matching original stack trace ...]
    at process._fatalException (node:internal/process/execution:178:25) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'kill'
}

Node.js v21.7.2

SO, this is clearly not a programming issue. It appears to be an issue between nodejs and sqlite3. I've reported this on both sites but am totally stuck in the water!

@RedYetiDev RedYetiDev closed this as not planned Won't fix, can't repro, duplicate, stale Jun 18, 2024
@RedYetiDev
Copy link
Member

This appears to be an issue with a specific package. Please report to them and obtain more information about whether this is actually a problem with node before reporting an issue

Thank you

@RedYetiDev RedYetiDev added wrong repo and removed question needs more info issues that need more info from the author labels Jun 18, 2024
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

2 participants