bcrypt@1.0.3 install: `node-pre-gyp install --fall

2019-06-04 21:35发布

问题:

While installing bcrypt I'm getting this error in my windows machine, I'm using

  • node v8.9.4
  • npm v5.6.0
  • bcrypt v1.0.3

C:\Users\user\Desktop\mysql_node_api\register_login\register_login>npm install bcrypt --save > bcrypt@1.0.3 install C:\Users\user\Desktop\mysql_node_api\register_login\regis ter_login\node_modules\bcrypt > node-pre-gyp install --fallback-to-build node-pre-gyp ERR! Tried to download(undefined): https://github.com/kelektiv/node .bcrypt.js/releases/download/v1.0.3/bcrypt_lib-v1.0.3-node-v57-win32-x64.tar.gz node-pre-gyp ERR! Pre-built binaries not found for bcrypt@1.0.3 and node@8.9.4 ( node-v57 ABI) (falling back to source compile with node-gyp) gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT HON env variable. gyp ERR! stack at PythonFinder.failNoPython (C:\Users\user\AppData\Roaming\n pm\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19) gyp ERR! stack at PythonFinder. (C:\Users\user\AppData\Roaming\np m\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16) gyp ERR! stack at C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_mo dules\graceful-fs\polyfills.js:284:29 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\user\AppData \Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "co nfigure" "--fallback-to-build" "--module=C:\Users\user\Desktop\mysql_node_ap i\register_login\register_login\node_modules\bcrypt\lib\binding\bcrypt_li b.node" "--module_name=bcrypt_lib" "--module_path=C:\Users\user\Desktop\mysq l_node_api\register_login\register_login\node_modules\bcrypt\lib\binding" gyp ERR! cwd C:\Users\user\Desktop\mysql_node_api\register_login\register_login\ node_modules\bcrypt gyp ERR! node -v v8.9.4 gyp ERR! node-gyp -v v3.6.2 gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.e xe C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\ node-gyp.js configure --fallback-to-build --module=C:\Users\user\Desktop\mysql_n ode_api\register_login\register_login\node_modules\bcrypt\lib\binding\bcrypt_lib .node --module_name=bcrypt_lib --module_path=C:\Users\user\Desktop\mysql_node_ap i\register_login\register_login\node_modules\bcrypt\lib\binding' (1) node-pre-gyp ERR! stack at ChildProcess. (C:\Users\user\Desktop\m ysql_node_api\register_login\register_login\node_modules\node-pre-gyp\lib\util\c ompile.js:83:29) node-pre-gyp ERR! stack at emitTwo (events.js:126:13) node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7) node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16) node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/chi ld_process.js:209:5) node-pre-gyp ERR! System Windows_NT 6.1.7601 node-pre-gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\user \Desktop\mysql_node_api\register_login\register_login\node_modules\node-pr e-gyp\bin\node-pre-gyp" "install" "--fallback-to-build" node-pre-gyp ERR! cwd C:\Users\user\Desktop\mysql_node_api\register_login\regist er_login\node_modules\bcrypt node-pre-gyp ERR! node -v v8.9.4 node-pre-gyp ERR! node-pre-gyp -v v0.6.36 node-pre-gyp ERR! not ok Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\user\AppData\Roamin g\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallbac k-to-build --module=C:\Users\user\Desktop\mysql_node_api\register_login\register _login\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\user\Desktop\mysql_node_api\register_login\register_login \node_modules\bcrypt\lib\binding' (1) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bcrypt@1.0.3 install: node-pre-gyp install --fallback-to-build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the bcrypt@1.0.3 install script. npm ERR!

This is probably not a problem with npm. There is likely additional log ging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\user\AppData\Roaming\npm-cache_logs\2018-02-25T14_42_29_5 29Z-debug.log

回答1:

Finally after many research I solve this problem. So, guys those who are facing this problem just do the below processes,

I just installed python and set the environment variables now it's working perfect for me.

  • Install Python (while installing in windows you can get the option for add path in environment variables, just tick the check box or else)
  • Set the path in environment variables
  • Now store the downloaded python.exe file in this directory "c:\Python\27\python.exe"
  • Now run this cmd in terminal npm config set python "c:\Python\27\python.exe"

Now do npm install or run your project. I think now your problem is solved. :-)