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

Error: Cannot find module '../build/better_sqlite3.node' #214

Closed
andreescocard opened this issue Dec 26, 2018 · 32 comments
Closed

Error: Cannot find module '../build/better_sqlite3.node' #214

andreescocard opened this issue Dec 26, 2018 · 32 comments

Comments

@andreescocard
Copy link

andreescocard commented Dec 26, 2018

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

info using [email protected]
info using [email protected]

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

@EthanLawr
Copy link

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

@sleepadru
Copy link

sleepadru commented Dec 27, 2018

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)

@andreescocard
Copy link
Author

@sleepadru tried the node-gyp rebuild on the folders and the same error happened :/
i guess that is something related to node
what is your node version?
thanks

@sleepadru
Copy link

sleepadru commented Dec 27, 2018

Node: v8.6.0
NPM: v5.3.0
node-gyp: v3.8.0

You could also try copying the things from better-sqlite3/build/Release folder down to the build folder immediately below it, it seems that it’s looking for the files in the Release folder that would normally get copied to the build folder but aren’t

I never used the LZZ_COMPAT =1 flag though, so I don’t know if that has anything to do with it

@JoshuaWise
Copy link
Member

The LZZ_COMPAT flag was used in previous versions of better-sqlite3, but is no longer in use.

@wruiqi
Copy link

wruiqi commented Jan 4, 2019

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)

@EliotChignell
Copy link

Having the same problem...

@andreescocard
Copy link
Author

Tried almost everything, nothing works.
Better_sqlite3 worked before i updated my environment, but now using the latest versions, i'm stuck

My environment:
Node: v11.4.0
NPM: v6.4.1
node-gyp: v3.8.0

@mandaputtra
Copy link

Copying file from better-sqlite3/build/Release solved for me. Dont know why

@andreescocard
Copy link
Author

In my case, there is no Release folder, only deps

@JoshuaWise
Copy link
Member

JoshuaWise commented Jan 28, 2019

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.

@thanhbinh2604
Copy link

thanhbinh2604 commented Mar 6, 2019

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

@Enderisss
Copy link

Does anyone actually know how to fix this dumb issue? No suggestion suggested from above actually work.

@hgdly
Copy link

hgdly commented May 9, 2019

Same error... i have tried to uninstall the module but nothing happens...

@Miky88
Copy link

Miky88 commented May 11, 2019

same error, nothing worked. Give me help plsss

@andreescocard
Copy link
Author

I guess that the only way to solve this issue is to downgrade the node

@hgdly
Copy link

hgdly commented May 11, 2019

I guess that the only way to solve this issue is to downgrade the node

it's working ?

@Miky88
Copy link

Miky88 commented May 12, 2019 via email

@ghost
Copy link

ghost commented May 31, 2019

Hi there,

debugging this leads to the database.js file, which has the line:

const CPPDatabase = require('../build/better_sqlite3.node').Database;

but the build directory is not existing. Can you debug this or does anyone have help here?

Regards

@MineProDan
Copy link

MineProDan commented Jul 17, 2019

Simply running npm i better-sqlite3 fixed my problem ¯_(ツ)_/¯
(ik its an old thread but still)

@ghost
Copy link

ghost commented Aug 13, 2019

nercoposting probably but im pretty sure it had to do with the fact that you had two dots instead of one...

@JoshuaWise
Copy link
Member

@MacindowsRegistry require() paths are relative from the file they are used, so two dots are correct. The file is being loaded from /lib/database.js

@tadegenban
Copy link

i solved this on my side, i you find "make: Nothing to be done for `all'." during your installation, then you have the same problem with me.
it's a bug on old GNU make (3.80), try to use "make -v" to find your make version . i replace it with a newer GNU make (>=3.81) . you can set it in your PATH
$ make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.

@huan0118
Copy link

huan0118 commented Oct 24, 2019

我也出现类似的错误。还在寻找解决办法 node 12.1.0 npm 6.9.0|
image

@ghost
Copy link

ghost commented Oct 24, 2019

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

@taynotfound
Copy link

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

@sankhaKarunasekara
Copy link

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

@deryrahman
Copy link

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

@qiufeihong2018
Copy link

having the same issue in 2021

@KrabsWong
Copy link

KrabsWong commented Jul 4, 2022

And now, it's 2022, have the same issue.

Try to downgrade Node.js, reinstall better-sqlite3 and @types/better-sqlite3, npm rebuild.

@KrabsWong
Copy link

Copying file from better-sqlite3/build/Release solved for me. Dont know why

Copy to which place?

@martin-braun
Copy link

@JoshuaWise Can you please re-open this, I still experience this issue.

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

No branches or pull requests