简体   繁体   English

npm安装bcrypt,gyp错误! 蟒蛇

[英]npm install bcrypt, gyp ERR! python

on windows 10 node:v6.7.0, npm:v4.0.1 node-gyp:v3.4.0, I am trying to npm install --save bcrypt that I face these errors. 在Windows 10 node:v6.7.0,npm:v4.0.1 node-gyp:v3.4.0上,我正在尝试npm install --save bcrypt ,我遇到这些错误。 this is where I have both, python27 and python35-32 in my path. 这是我的路径中同时拥有python27和python35-32的地方。

D:\myApp\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Users\myname\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Python executable "C:\Users\myname\AppData\Local\Programs\Python\Python35-32\python.EXE" is v3.5.2, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.
gyp ERR! stack     at failPythonVersion (C:\Users\Amirhossein\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:14) ....

I tried to install with npm install --save --python=phyton2.7 bcrypt 我尝试使用npm install --save --python=phyton2.7 bcrypt

it seems ok, but finished installing with lots of warnings: 看起来还可以,但是完成安装时出现了很多警告:

D:\myApp\node_modules\bcrypt>if not defined npm_config_node_gyp (node "C:\Users\myname\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  blowfish.cc
  bcrypt.cc
  bcrypt_node.cc
  win_delay_load_hook.cc
..\src\bcrypt.cc(232): warning C4267: '=': conversion from 'size_t' to 'unsigned char', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(76): warning C4244: 'argument': conversion from 'ssize_t' to 'unsigned char', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(229): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
..\src\bcrypt_node.cc(230): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data [D:\myApp\node_modules\bcrypt\build\bcrypt_lib.vcxproj]

will it work correctly? 它能正常工作吗? what is the proper way of installing bcrypt? 安装bcrypt的正确方法是什么? should I modify config at node-gyp? 我应该在node-gyp修改配置吗?

You could also install Python2.x in your Operating System and run: 您也可以在操作系统中安装Python2.x并运行:

npm config set python /path/to/python2.x

This solved the problem for me, hope is helpful to somebody. 这为我解决了问题,希望对大家有所帮助。

最简单的解决方案:抛弃python bcrypt并改用bcrypt-nodejs: https : //github.com/shaneGirish/bcrypt-nodejs

If you are open to ditching bcrypt, I would suggest to use bcryptjs , which is compatible with bcrypt with zero dependencies. 如果您愿意放弃bcrypt,我建议您使用bcryptjs ,它与零依赖的bcrypt兼容。 Yes, that will incur a performance hit , but if you're OK with that, it will get you out of node-gyp rebuild hell. 是的,这会带来性能上的损失 ,但是如果您对此表示满意,那么它将使您摆脱node-gyp的重建困境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM