2016-11-18 115 views
0

在Windows 10節點:v6.7.0,npm:v4.0.1 node-gyp:v3.4.0,我試圖npm install --save bcrypt,我面對這些錯誤。這是我的路徑中的python27和python35-32。npm安裝bcrypt,gyp ERR!蟒蛇

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的配置嗎?

回答

2

最簡單的辦法:溝蟒蛇bcrypt和使用bcrypt-的NodeJS代替:https://github.com/shaneGirish/bcrypt-nodejs

+1

這是功能等效嗎? –

+1

恕我直言,如果你不關心性能,那就沒問題了(是的,我知道bcrypt的用途,但在純JavaScript中進行bcrypt時仍然存在不必要的性能問題)。 – mscdex

-1

如果只有警告,沒有編譯錯誤(這將是顯而易見的,因爲你會看到從NPM文本塊告訴你安裝插件時出現問題),那麼它應該工作得很好。

0

如果您打算開始加密bcrypt,我會建議使用bcryptjs,它與bcrypt與零依賴關係兼容。 是的,那會產生一個performance hit,但是如果你沒問題,它會讓你脫離node-gyp重建地獄。