better-sqlite3: Error: Cannot find module '../build/better_sqlite3.node'

Running on a raspberry pi 3, getting this error Tried using LZZ_COMPAT=1, no success

info using npm@6.4.1 info using node@v11.4.0

Log:

Error: Cannot find module '../build/better_sqlite3.node'
[1]     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:529:25)
[1]     at Module.require (internal/modules/cjs/loader.js:659:17)
[1]     at require (internal/modules/cjs/helpers.js:22:18)
[1]     at Object.<anonymous> (/home/pi/instapy-dashboard/node_modules/better-sqlite3/lib/database.js:5:21)
[1]     at Module._compile (internal/modules/cjs/loader.js:723:30)
[1]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
[1]     at Module.load (internal/modules/cjs/loader.js:620:32)
[1]     at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
[1]     at Function.Module._load (internal/modules/cjs/loader.js:552:3)
[1] npm ERR! code ELIFECYCLE
[1] npm ERR! errno 1

Any tips? Thanks

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 32 (3 by maintainers)

Most upvoted comments

npm uninstall better-sqlite3-helper -g npm uninstall better-sqlite3-helper --save npm i better-sqlite3-helper --save it worked

Hey, it’s probably late, but if any of you are having this problem while using Glitch, you may run the following command in the console: enable-pnpm

I was able to get it running by doing node-gyp rebuild in both the integer and better-sqlite3 folders under node_modules. Hopefully this works for you!

(Took a while for me to find out exactly was messing up, but I think that it’s just node-gyp being weird)

im having that too. tried all the troubleshooting stuff and whatnot. No luck

I hate the same problem…

internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module '../build/better_sqlite3.node'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (C:\Users\jotar\OneDrive\Desktop\GitHub\Kaiso\node_modules\better-sqlite3\lib\database.js:5:21)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)

having the same issue in 2021, solved it by running npm rebuild hope it helps.

fixed. thanks anyways

Miky

Il Sab 11 Mag 2019, 22:19 hug0 notifications@github.com ha scritto:

I guess that the only way to solve this issue is to downgrade the node it’s working ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JoshuaWise/better-sqlite3/issues/214#issuecomment-491540888, or mute the thread https://github.com/notifications/unsubscribe-auth/AKWSZ7NM65GWRQE2AY6DAR3PU4S5DANCNFSM4GMHJY3A .

For those who are using typescript, installing both @types/better-sqlite3 and better-sqlite3 will solve the problem.

npm install @types/better-sqlite3 better-sqlite3

Welp. I’m still having this issue in 2021. The latest install of Quick.db complains abt not having .node files in the builds folder

better-sqlite3 is built by node-gyp, which is the standard way of building any native addon for Node.js.

After the binaries are built, we utilize a node-gyp command called copies:

"copies": [{
  "files": ["<(PRODUCT_DIR)/better_sqlite3.node"],
  "destination": "build",
}],

Since this command is provided by node-gyp, I assume that it works on every platform. However, it seems like the issue described in this thread is likely related to this copies command not working as expected.

If the command is indeed supported on every platform, it’s possible that the copy is failing due to incorrect permissions or something similar.