我已经将node.js v6.9.1和npm版本4.1.2一起安装了,并且我已经将这个组合用于某些项目
现在我想在我的项目中使用bcrypt
npm包,但是安装失败了
npm install bcrypt --save
我还试图用admin权限运行此命令,但无济于事
这是我得到的错误
> bcrypt@1.0.2 install C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcry
pt
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://github.com/kelektiv/node.bcryp
t.js/releases/download/v1.0.2/bcrypt_lib-v1.0.2-node-v48-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for bcrypt@1.0.2 and node@6.9.1 (
node-v48 ABI) (falling back to source compile with node-gyp)
C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt>if not defined npm_c
onfig_node_gyp (node "C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\bin
\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" clean ) else (node
"" clean )
C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt>if not defined npm_c
onfig_node_gyp (node "C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\bin
\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" configure --fallback
-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\l
ib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\tthei
ner\NodeProjects\authtest\node_modules\bcrypt\lib\binding ) else (node "" confi
gure --fallback-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_m
odules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path
=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding )
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 Object.failNoPython (C:\Users\ttheiner\AppData\Roaming\npm
\node_modules\npm\node_modules\node-gyp\lib\configure.js:454:19)
gyp ERR! stack at Object.<anonymous> (C:\Users\ttheiner\AppData\Roaming\npm\
node_modules\npm\node_modules\node-gyp\lib\configure.js:480:16)
gyp ERR! stack at C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\nod
e_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\App
Data\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js"
"configure" "--fallback-to-build" "--module=C:\\Users\\ttheiner\\NodeProjects\\
authtest\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bc
rypt_lib" "--module_path=C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modul
es\\bcrypt\\lib\\binding"
gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd configure --fallb
ack-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcryp
t\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\tt
heiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\ttheiner\NodeP
rojects\authtest\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/chi
ld_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 6.1.7601
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\tthe
iner\\NodeProjects\\authtest\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "in
stall" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcryp
t
node-pre-gyp ERR! node -v v6.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd configure --fallback-to-build --module=C:\Users\
ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding\bcrypt_lib.node -
-module_name=bcrypt_lib --module_path=C:\Users\ttheiner\NodeProjects\authtest\no
de_modules\bcrypt\lib\binding' (1)
npm WARN authtest@1.0.0 No repository field.
npm WARN authtest@1.0.0 No license field.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\AppDat
a\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "bcrypt" "--save"
npm ERR! node v6.9.1
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! bcrypt@1.0.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@1.0.2 install script 'node-pre-gyp install --fallb
ack-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\ttheiner\NodeProjects\authtest\npm-debug.log
问题似乎是npm无法找到预先构建的二进制文件,所以它尝试使用python编译源代码(我似乎没有)。
我需要为此安装python吗?如果是的话,你能指出我正确的方向吗?是不是没有预先构建的bcrypt版本?
编辑:安装Python 2.7后,错误发生变化......似乎它试图使用MSBuild编译一些C ++代码。C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(366,5): warning MSB8003: Could not find WindowsSDKDir var
iable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. [C:\Users\ttheiner\NodeProject
s\authtest\node_modules\bcrypt\build\bcrypt_lib.vcxproj]
TRACKER : error TRK0005: Failed to locate: "CL.exe". The system cannot find the file specified. [C:\Users\ttheiner\NodeProjects\authtest\no
de_modules\bcrypt\build\bcrypt_lib.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\ttheiner\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gy
p\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\bcrypt\\lib\\binding
\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\bcrypt\\lib\\binding
"
gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\no
de_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bc
rypt\lib\binding' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\ttheiner\NodeProjects\authtest\node_modules\node-pre-gyp\lib\util\compile.
js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 6.1.7601
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\node-pre-gyp\\bi
n\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt
node-pre-gyp ERR! node -v v6.9.1
node-pre-gyp ERR! node-pre-gyp -v v0.6.32
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd build --fallback-to-build --module=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding\b
crypt_lib.node --module_name=bcrypt_lib --module_path=C:\Users\ttheiner\NodeProjects\authtest\node_modules\bcrypt\lib\binding' (1)
npm WARN authtest@1.0.0 No repository field.
npm WARN authtest@1.0.0 No license field.
npm WARN Error: EPERM: operation not permitted, scandir 'C:\Users\ttheiner\NodeProjects\authtest\node_modules\dashdash\node_modules'
npm WARN at Error (native)
npm WARN { Error: EPERM: operation not permitted, scandir 'C:\Users\ttheiner\NodeProjects\authtest\node_modules\dashdash\node_modules'
npm WARN at Error (native)
npm WARN errno: -4048,
npm WARN code: 'EPERM',
npm WARN syscall: 'scandir',
npm WARN path: 'C:\\Users\\ttheiner\\NodeProjects\\authtest\\node_modules\\dashdash\\node_modules' }
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ttheiner\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "instal
l" "bcrypt" "--save"
npm ERR! node v6.9.1
npm ERR! npm v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! bcrypt@1.0.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@1.0.2 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bcrypt
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bcrypt
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\ttheiner\NodeProjects\authtest\npm-debug.log
答案 0 :(得分:8)
我建议你使用bcrypt-nodejs:
它提供了几乎相同的功能,易于使用。
原始答案:
您可以尝试以下方法:
然后:
npm install node-gyp -g
npm install bcrypt -g
答案 1 :(得分:5)
我遇到过相同或至少类似的错误。 在尝试安装bcrypt之前运行以下内容为我解决了这个问题:
npm install --global --production windows-build-tools
答案 2 :(得分:2)
我今天在尝试在Windows 10桌面上安装bcrypt时也遇到了同样的问题。事实证明,bcrypt支持稳定版本的node更好地检查了docs
对我来说,解决方案是:
npm install --global --production windows-build-tools
npm install bcrypt --save
此后一切正常。
答案 3 :(得分:0)
在处理节点API项目时。
解决方案
rm -rf node_modules / bcrypt
npm install node-gyp -g
npm install bcrypt @ [VERSION] -g
在第10窗口上对我有用。
答案 4 :(得分:-1)
我也遇到了这个错误。
我使用此命令npm install node-gyp -g
重新安装node-gyp
之后,我使用npm install bcrypt
重新安装bccrypt
终于可以了