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 '...../bcrypt/lib/binding/napi-v3/bcrypt_lib.node' #800

Closed
jellohouse opened this issue May 13, 2020 · 27 comments
Closed

Comments

@jellohouse
Copy link

After installing the newest version of node 12.6.3 and installing bcrypt 4.0.1 in my project,
"npm install bcrypt" added the package successfully without errors, but then running "node app.js" I get:

Error: Cannot find module 'path_to_my_project/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'

And indeed the folder node_modules/bcrypt/lib is not there at all...

Why would installation not make this folder?
I suspect it's something to do with node-gyp not doing it's thing, but why don't I get an error message when i do npm install?

And I tried reverting to my old node version 8.11.1 using https://www.npmjs.com/package/n to manage my node versions and then installing bcrypt 2.0.1 (like I had previously), but it's behaving the exact same way... npm install adds the package but the bcrypt/lib folder is missing.
I also tried with node 12.6.1 and 12.6.2, same thing.

@jellohouse
Copy link
Author

jellohouse commented May 14, 2020

Ok for anyone else having this issue here is how I solved it, I had to compile it manually for some reason:
cd node_modules/bcrypt
node-pre-gyp install --fallback-to-build

@spicecoder
Copy link

node-pre-gyp install --fallback-to-build.. solved my issue too thanks

@joy45689
Copy link

joy45689 commented Oct 6, 2020

Ok for anyone else having this issue here is how I solved it, I had to compile it manually for some reason:
cd node_modules/bcrypt
node-pre-gyp install --fallback-to-build

It solves my problem too. Thanks.

@vishalims095
Copy link

sudo npm i --unsafe-perm
after that install bcrypt

its works for me ubuntu 18.04

@lehathanh
Copy link

Ok for anyone else having this issue here is how I solved it, I had to compile it manually for some reason:
cd node_modules/bcrypt
node-pre-gyp install --fallback-to-build

This works for me on newly installation on Windows 10/VSC, nodeJS v14.15.1. Thanks a lot!

@lusm554
Copy link

lusm554 commented Jan 15, 2021

Ok for anyone else having this issue here is how I solved it, I had to compile it manually for some reason:
cd node_modules/bcrypt
node-pre-gyp install --fallback-to-build

It helps me. Thanks

@AITuring
Copy link

if mac still have problems after node-pre-gyp install --fallback-to-build, maybe it's mac problem. You should fix xcun.

@Shishoo
Copy link

Shishoo commented Feb 23, 2021

node version: 14.16.0 (LTS)
npm version: 6.14.11
bcrypt: bcrypt@5.0.0
OS: Windows 10

I get the following error:

internal/modules/cjs/loader.js:883
  throw err;
  ^
 
Error: Cannot find module '...path...\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node'
Require stack:
- ...path...\node_modules\bcrypt\bcrypt.js
- ...path...\crypto.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (...path...\node_modules\bcrypt\bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '...path...\\node_modules\\bcrypt\\bcrypt.js',
    '...path...\\crypto.js'
  ]
}

I have tried the fixes here and here and haven't been able to resolve the issue.

@recrsn
Copy link
Collaborator

recrsn commented Feb 24, 2021

@Shishoo it appears that your bcrypt DLL is missing. Run npm rebuild bcrypt

@Shishoo
Copy link

Shishoo commented Feb 24, 2021

@recrsn
Hi Amitosh - with reference to your previous post here on 27/12/2017, I did try
npm rebuild bcrypt - unfortunately this didn't work.

@recrsn
Copy link
Collaborator

recrsn commented Feb 24, 2021

What's the error while trying to rebuild?

Do you have an outer layer of package.json?

@Shishoo
Copy link

Shishoo commented Feb 24, 2021

@recrsn

There is NO error when I run npm rebuild bcrypt

Here is everything I have encountered and contained within the project directory:

----------------------------------------------------
> npm i bcrypt
----------------------------------------------------

npm WARN deprecated node-pre-gyp@0.15.0: Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN bcrypto@1.0.0 No description
npm WARN bcrypto@1.0.0 No repository field.

+ bcrypt@5.0.0
added 68 packages from 116 contributors and audited 68 packages in 13.075s

1 package is looking for funding
  run `npm fund` for details    

found 0 vulnerabilities

--------------------------------------------------
> node app.js
----------------------------------------------------

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

Error: Cannot find module 'F:\...path-to-file\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node'
Require stack:
- F:\...path-to-file\bcrypto\node_modules\bcrypt\bcrypt.js
- F:\...path-to-file\bcrypto\app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (F:\...path-to-file\node_modules\bcrypt\bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'F:\\...path-to-file\\node_modules\\bcrypt\\bcrypt.js',
    'F:\\...path-to-file\\bcrypto\\app.js'
  ]
}

----------------------------------------------------
> npm rebuild bcrypt
----------------------------------------------------

bcrypt@5.0.0 F:\...path-to-file\bcrypto\node_modules\bcrypt

**(No errors or warnings)**

----------------------------------------------------
> node app.js
----------------------------------------------------

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

Error: Cannot find module 'F:\...path-to-file\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node'
Require stack:
- F:\...path-to-file\bcrypto\node_modules\bcrypt\bcrypt.js
- F:\...path-to-file\bcrypto\app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (F:\...path-to-file\node_modules\bcrypt\bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'F:\\...path-to-file\\node_modules\\bcrypt\\bcrypt.js',
    'F:\\...path-to-file\\bcrypto\\app.js'
  ]
}

----------------------------------------------------
contents of: package.json
----------------------------------------------------

{
  "name": "bcrypto",
  "version": "1.0.0",
  "description": "testing bcrypt",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^5.0.0"
  }
}

----------------------------------------------------
contents of: app.js
----------------------------------------------------

// REF: https://www.npmjs.com/package/bcrypt
const bcrypt = require('bcrypt');

pwd = '£MonkeyMa9ic';

const hashPassword = async (pwd) => {
  const salt = await bcrypt.genSalt(11);
  const hash = await bcrypt.hash(pwd, salt)

  console.log(salt);
  console.log(hash);
};

@manoharreddyporeddy
Copy link

manoharreddyporeddy commented Mar 24, 2021

Below solved the issue:

  1. // delete node_modules , or rename node_modules to something else
  2. npm cache clean --force
  3. npm i

@sk8Guerra
Copy link

@Shishoo it appears that your bcrypt DLL is missing. Run npm rebuild bcrypt

Thanks man! That helped solve the error.

@XiaoyunWu6666
Copy link

Ok for anyone else having this issue here is how I solved it, I had to compile it manually for some reason:
cd node_modules/bcrypt
node-pre-gyp install --fallback-to-build

The only answer online that eventually helped me :)

@jongomes
Copy link

not work me

@mgalvao2012
Copy link

I fixed this issue this way. On the terminal from root folder of the project:
cd node_modules/bcrypt
make

@duttaANI
Copy link

I fixed this issue this way. On the terminal from root folder of the project: cd node_modules/bcrypt make

This solved the issue. Thanks a lot.

@AhmedHajeyah
Copy link

I fixed this issue this way. On the terminal from root folder of the project: cd node_modules/bcrypt make

Solved my issue

@axel-lukongo
Copy link

sudo npm i --unsafe-permaprès cela, installez bcrypt

ça marche pour moi ubuntu 18.04

ça à aussi fonctionner pour moi et je suis sur Mac os

@Samuelfapohunda
Copy link

@Shishoo it appears that your bcrypt DLL is missing. Run npm rebuild bcrypt

This worked for me

@maztak
Copy link

maztak commented Nov 22, 2023

i use pnpm and node.js@18.16.0.
i have to use pnpm@8.3. pnpm@8.10 deesn't work.

@cookabc
Copy link

cookabc commented Dec 5, 2023

I fixed this issue this way. On the terminal from root folder of the project: cd node_modules/bcrypt make

save my day, thank you sir!

@codebyBowen
Copy link

Ok for anyone else having this issue here is how I solved it, I had to compile it manually for some reason: cd node_modules/bcrypt node-pre-gyp install --fallback-to-build

Big thanks, works for me

@Gxmadix
Copy link

Gxmadix commented Dec 23, 2023

I was missing node-gyp on my system, after installing it and rebuilding like told by @recrsn npm rebuild bcrypt this solved my issue

@lutfi-haslab
Copy link

this work for me, for macbook air m1
#800 (comment)

@kireerik
Copy link

kireerik commented Oct 25, 2024

This is (still) occurring on Windows ARM (using pnpm) and we are getting the following error:

node_modules/.pnpm/bcrypt@5.1.1/node_modules/bcrypt: Running install script, failed in 652ms
.../bcrypt@5.1.1/node_modules/bcrypt install$ node-pre-gyp install --fallback-to-build
│ node-pre-gyp info it worked if it ends with ok
│ node-pre-gyp info using node-pre-gyp@1.0.11
│ node-pre-gyp info using node@23.0.0 | win32 | arm64
│ (node:34648) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
│ (Use `node --trace-deprecation ...` to show where the warning was created)
│ node-pre-gyp info check checked for "...\node_modules\.pnpm\bcrypt@5.1.1\node_modules\bcrypt\lib\binding\napi-v3\bcrypt_lib.node" (not found)
│ node-pre-gyp http GET https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.1.1/bcrypt_lib-v5.1.1-napi-v3-win32-arm64-unknown.tar.gz
│ node-pre-gyp ERR! install response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.1.1/bcrypt_lib-v5.1.1-napi-v3-win32-arm64-unknown.tar.gz
│ node-pre-gyp WARN Pre-built binaries not installable for bcrypt@5.1.1 and node@23.0.0 (node-v131 ABI, unknown) (falling back to source compile with node-gyp)
│ node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.1.1/bcrypt_lib-v5.1.1-napi-v3-win32-arm64-unknown.tar.gz
│ node-pre-gyp ERR! UNCAUGHT EXCEPTION
│ node-pre-gyp ERR! stack Error: spawn EINVAL
│ node-pre-gyp ERR! stack     at ChildProcess.spawn (node:internal/child_process:421:11)
│ node-pre-gyp ERR! stack     at Object.spawn (node:child_process:753:9)
│ node-pre-gyp ERR! stack     at module.exports.run_gyp (...\node_modules\.pnpm\@mapbox+node-pre-gyp@1.0.11\node_modules\@mapbox\node-pre-gyp\lib\util\compile.js:80:18)
│ node-pre-gyp ERR! stack     at build (...\node_modules\.pnpm\@mapbox+node-pre-gyp@1.0.11\node_modules\@mapbox\node-pre-gyp\lib\build.js:41:13)
│ node-pre-gyp ERR! stack     at self.commands.<computed> [as build] (...\node_modules\.pnpm\@mapbox+node-pre-gyp@1.0.11\node_modules\@mapbox\node-pre-gyp\lib\node-pre-gyp.js:86:37)
│ node-pre-gyp ERR! stack     at run (...\node_modules\.pnpm\@mapbox+node-pre-gyp@1.0.11\node_modules\@mapbox\node-pre-gyp\lib\main.js:81:30)
│ node-pre-gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:85:11)
│ node-pre-gyp ERR! System Windows_NT 10.0.26100
│ node-pre-gyp ERR! command "...\\nodejs\\node.exe" "...\\node_modules\\.pnpm\\bcrypt@5.1.1\\node_modules\\@mapbox\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
│ node-pre-gyp ERR! cwd ...\node_modules\.pnpm\bcrypt@5.1.1\node_modules\bcrypt
│ node-pre-gyp ERR! node -v v23.0.0
│ node-pre-gyp ERR! node-pre-gyp -v v1.0.11
└─ Failed in 652ms at ...\node_modules\.pnpm\bcrypt@5.1.1\node_modules\bcrypt
 ELIFECYCLE  Command failed with exit code 7.

 
A temporary workaround is to get the missing file from an existing asset manually from the releases (bcrypt_lib-v5.1.1-napi-v3-win32-x64-unknown.tar.gz can be used), since the install script is trying to access an asset that does not exist (bcrypt_lib-v5.1.1-napi-v3-win32-arm64-unknown.tar.gz (only bcrypt_lib-v5.1.1-napi-v3-win32-x64-unknown.tar.gz exists)) and then copy the missing asset into the folder where it is missing from.

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

No branches or pull requests