node.bcrypt.js icon indicating copy to clipboard operation
node.bcrypt.js copied to clipboard

“npm install bcrypt” failing with “Error: Cannot find module 'nan'”

Open kissenger opened this issue 7 years ago • 8 comments

I'm trying to get my existing Angular project working on a new laptop and getting it up and running is driving me crazy. Here is what I have done:

git init 
git clone <project>
cd <project directory>
delete package-lock.json
npm install
npm install --global --production windows-build-tools
npm install bcrypt

I have checked node_modules folder, and the 'nan' dependency does exist. even so, I tried installing it again (both locally and globally per https://stackoverflow.com/questions/9704660/node-error-cannot-find-module-already-installed) and it installs fine. 'nan' is also listed in the package.json file.

I have tried:

  • This: https://stackoverflow.com/questions/34464673/error-cannot-find-module-nan
  • Uninstalling node like this: https://stackoverflow.com/questions/20711240/how-to-completely-remove-node-js-from-windows and also uninstalling all python installations I can find on the computer (including a v3 installation I thought might have been conflicting, but that doesn't seem to have been the problem).
  • Other than that google is coming up blank.
  • Taking a break and waiting for divine inspiration didn't work either.

Here is the error:

node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.3/bcrypt_lib-v3.0.3-node-v64-win32-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI, unknown) (falling back to source compile with node-gyp)
internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'nan'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at [eval]:1:1
    at Script.runInThisContext (vm.js:96:20)
    at Object.runInThisContext (vm.js:303:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at evalScript (internal/bootstrap/node.js:587:27)
gyp: Call to 'node -e "require('nan')"' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=C:\\project\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\project\\node_modules\\bcrypt\\lib\\binding" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v64" "--python=C:\\Users\\xxxxx\\.windows-build-tools\\python27\\python.exe"

The nan package is def installed. When I run npm list nan, I get:

[email protected] C:\project
+-- @angular-devkit/[email protected]
| `-- [email protected]
|   `-- [email protected]  deduped
+-- @angular/[email protected]
| `-- [email protected]
|   `-- UNMET OPTIONAL DEPENDENCY [email protected]
|     `-- [email protected]  deduped
`-- [email protected]

I also tried this and added environment variables, with no luck.

kissenger avatar Jan 21 '19 20:01 kissenger

SOLVED: Had to reinstall windows (relatively new laptop so not that painful) to solve the problem.

kissenger avatar Jan 22 '19 11:01 kissenger

@kissenger This is a draconian step. Did you find out what went wrong, ever?

recrsn avatar Mar 19 '19 18:03 recrsn

I have solve this Bug or Error by Folllowing method:

Step 1: Simply , Uninstall the bcrypt package by using command :

npm uninstall bcrypt

Step 2: Then ReInstall it

npm install bcrypt

BasitMaqsood avatar Jul 30 '19 04:07 BasitMaqsood

I have solve this Bug or Error by Folllowing method:

Step 1: Simply , Uninstall the bcrypt package by using command :

npm uninstall bcrypt

Step 2: Then ReInstall it

npm install bcrypt

work For me

rami-sweyri avatar Dec 30 '19 13:12 rami-sweyri

I have solve this Bug or Error by Folllowing method: Step 1: Simply , Uninstall the bcrypt package by using command : npm uninstall bcrypt Step 2: Then ReInstall it npm install bcrypt

work For me

thanks man you saved my day

visotechsolutions avatar Apr 22 '20 19:04 visotechsolutions

I have solve this Bug or Error by Folllowing method:

Step 1: Simply , Uninstall the bcrypt package by using command :

npm uninstall bcrypt

Step 2: Then ReInstall it

npm install bcrypt

its worked for me too.thanks dude

MTavakolikia avatar May 09 '20 11:05 MTavakolikia

我已经通过以下方法解决了此错误或错误:

步骤1:简单地,使用以下命令卸载bcrypt软件包:

npm卸载bcrypt

步骤2:然后重新安装

npm安装bcrypt

thanks !

ZhuQiWei1998 avatar Jul 08 '20 09:07 ZhuQiWei1998

I have solve this Bug or Error by Folllowing method:

Step 1: Simply , Uninstall the bcrypt package by using command :

npm uninstall bcrypt

Step 2: Then ReInstall it

npm install bcrypt

thanks, it works for me

aliazimoshan avatar Aug 31 '20 20:08 aliazimoshan