:v6.7.0,npm:v4.0.1 node-gyp:v3.4.0,我正在尝试npm install --save bcrypt
我遇到这些错误。这是我在路径中同时拥有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) ....
我尝试使用npm install --save --python=phyton2.7 bcrypt
看起来没问题,但是安装完了许多警告:
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]
它会正常工作吗?安装bcrypt的正确方法是什么?我应该在node-gyp修改配置吗?
答案 0 :(得分:2)
最简单的解决方案:沟通python bcrypt并改为使用bcrypt-nodejs:https://github.com/shaneGirish/bcrypt-nodejs
答案 1 :(得分:1)
您还可以在操作系统中安装Python2.x并运行:
npm config set python /path/to/python2.x
这为我解决了问题,希望对某人有帮助。
答案 2 :(得分:0)
如果您愿意放弃bcrypt,我建议使用bcryptjs,它与没有依赖关系的bcrypt兼容。 是的,这会产生一个performance hit,但是如果你对它没问题,它会让你走出node-gyp重建地狱。
答案 3 :(得分:-2)
如果只有警告而且没有编译器错误(这很明显,因为你会看到来自npm的文本块告诉你安装插件时出现问题),那么它应该可行细