我想为节点安装bcrypt软件包,但是node-gyp有问题。
我安装了(Visual Studio Build Tools 2017)(C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools
)和Python 2.7.16(C:/Python27/python.exe
)
完整的控制台输出:
node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/kelektiv/node.bcrypt.js/releases/download/v3.0.6/bcrypt_lib-v3.0.6-node-v72-win32-x64-unknown.tar.gz
node-pre-gyp WARN Pre-built binaries not found for bcrypt@3.0.6 and node@12.4.0 (node-v72 ABI, unknown) (falling back to source compile with node-gyp)
Traceback (most recent call last):
File "X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
sys.exit(gyp.script_main())
File "X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 545, in script_main
return main(sys.argv[1:])
File "X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 538, in main
return gyp_main(args)
File "X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 514, in gyp_main
options.duplicate_basename_check)
File "X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 98, in Load
generator.CalculateVariables(default_variables, params)
File "X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1916, in CalculateVariables
generator_flags.get('msvs_version', 'auto'))
File "X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\gyp\pylib\gyp\MSVSVersion.py", line 434, in SelectVisualStudioVersion
versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2017'
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:200:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command "X:\\Program Files\\nodejs\\node.exe" "X:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--module=X:\\code\\toDoList\\node_modules\\bcrypt\\lib\\binding\\bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=X:\\code\\toDoList\\node_modules\\bcrypt\\lib\\binding" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72" "--python=c:\\Python27\\python.exe" "--msvs_version=2017"
gyp ERR! cwd X:\code\toDoList\node_modules\bcrypt
gyp ERR! node -v v12.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'X:\Program Files\nodejs\node.exe X:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --module=X:\code\toDoList\node_modules\bcrypt\lib\binding\bcrypt_lib.node --module_name=bcrypt_lib --module_path=X:\code\toDoList\node_modules\bcrypt\lib\binding --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72 --python=c:\Python27\python.exe --msvs_version=2017' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (X:\code\toDoList\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:200:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
node-pre-gyp ERR! System Windows_NT 10.0.18362
node-pre-gyp ERR! command "X:\\Program Files\\nodejs\\node.exe" "X:\\code\\toDoList\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd X:\code\toDoList\node_modules\bcrypt
node-pre-gyp ERR! node -v v12.4.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
npm WARN todolist@0.1.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bcrypt@3.0.6 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@3.0.6 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Roaming\npm-cache\_logs\2019-06-21T15_27_23_192Z-debug.log
我想在节点项目中使用bcrypt,它可以在Arch上运行,但不能在Windows上运行。
答案 0 :(得分:0)
我不太确定自己做了什么,但这对我来说是固定的。
我已卸载
我删除了对可能找到的npm / node的所有引用(%appdata%/ npm,%temp%)
重新安装Node,通过npm install -g node-gyp
和`npm install --global --production Windows-build-tools安装了node-gyp。还是没用。
但是后来我安装了Visual Studio 2019,它可以正常工作。
答案 1 :(得分:0)
以管理员身份运行Git Bash
npm install --global --production windows-build-tools node-gyp
PYTHON='C:\\Users\\[YOUR USER]\\.windows-build-tools\\python27\\python.exe'
export PYTHON
npm config set PYTHON
如果要使用命令提示符,则需要使用与“ export”等效的命令。