1

I'm working on an api project with node.js and receive this error while trying to hash my code with bcrypt package :

  throw err;
  ^

Error: Cannot find module '/home/emad/work/node.js/npm-demo/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'
Require stack:
- /home/emad/work/node.js/npm-demo/node_modules/bcrypt/bcrypt.js
- /home/emad/work/node.js/npm-demo/routes/users.js
- /home/emad/work/node.js/npm-demo/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/emad/work/node.js/npm-demo/node_modules/bcrypt/bcrypt.js:6:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/emad/work/node.js/npm-demo/routes/users.js:1:16)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/home/emad/work/node.js/npm-demo/index.js:8:14)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/emad/work/node.js/npm-demo/node_modules/bcrypt/bcrypt.js',
    '/home/emad/work/node.js/npm-demo/routes/users.js',
    '/home/emad/work/node.js/npm-demo/index.js'
  ]
}

My OS is a Ubuntu 18.04.5 LTS and I installed all the dependecies that was written down in bcrypt page in npm site

1 Answer 1

4

try below steps and run:-

  1. Delete node_modules folder
  2. run npm cache clean --force
  3. npm install
Sign up to request clarification or add additional context in comments.

2 Comments

FWIW, this fixed it for me. Running on a node docker container
Thanks for the solution. In my case it happened with zero messages, I had to debug the imports and then see it was failing at bcrypt... then I changed from import to require so I could see the error and found your suggestion. That's really bad.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.