npm i bcrypt
新系統拉取項目,下載依賴包,其中包含 bcrypt 依賴,一直安裝不成功。
gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
github issues 同樣的問題,可能生效的不同的方法
----
換了台電腦又遇到了,這次是回退 npm版本解決的問題。
---
已安裝號 Python 3 和 Visual Studio 2019。
此類型npm庫都會使用到 node-gyp ,依賴 Python 和 Visual Studio
npm ERR! gyp info using node-gyp@8.2.0 npm ERR! gyp info using node@14.18.1 | win32 | x64 npm ERR! gyp info find Python using Python version 3.10.0 found at "C:\Program Files\Python310\python.exe" npm ERR! gyp info find VS using VS2019 (16.11.31729.503) found at: npm ERR! gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community" npm ERR! gyp info find VS run with --verbose for detailed information npm ERR! gyp info spawn C:\Program Files\Python310\python.exe
最終卡在
npm ERR! gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1 npm ERR! gyp ERR! stack at ChildProcess.onCpExit (C:\Users\17212\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:353:16) npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:400:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
嘗試過清緩存,重裝,沒用。
npm cache clean -f npm uninstall node-gyp -g npm install node-gyp -g
使用,還是沒用
再次嘗試,沒效果。還是使用了Python 3,卸載了Python 3,程序報錯Python2不適用,必須要Python 3。
npm config set python C:\Python27\python.exe
安裝 Visual Studio 2017,設置 2017 ,也沒用。
npm config set msvs_version 2017 --global
最后到用戶目錄刪除了文件重新安裝,成功了。
刪除文件:C:\Users\***\AppData\Roaming\npm-cache、C:\Users\***\AppData\Roaming\npm\node_modules\npm、C:\Users\***\AppData\Roaming\npm\node_modules\node-gyp
只剩下了先前安裝的 windows-build-tools(使用了管理員shell安裝)
> bcrypt@5.0.1 install E:\workspace\cargo-mongo\node_modules\bcrypt > node-pre-gyp install --fallback-to-build node-pre-gyp ERR! install request to https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-win32-x64-unknown.tar.gz failed, reason: read ECONNRESET node-pre-gyp WARN Pre-built binaries not installable for bcrypt@5.0.1 and node@14.18.1 (node-v83 ABI, unknown) (falling back to source compile with node-gyp) node-pre-gyp WARN Hit error request to https://github.com/kelektiv/node.bcrypt.js/releases/download/v5.0.1/bcrypt_lib-v5.0.1-napi-v3-win32-x64-unknown.tar.gz failed, reason: read ECONNRESET 在此解決方案中一次生成一個項目。若要啟用並行生成,請添加“/m”開關。 nothing.c win_delay_load_hook.cc nothing.vcxproj -> E:\workspace\cargo-mongo\node_modules\bcrypt\build\Release\\nothing.lib blowfish.cc bcrypt.cc bcrypt_node.cc win_delay_load_hook.cc 正在創建庫 E:\workspace\cargo-mongo\node_modules\bcrypt\build\Release\bcrypt_lib.lib 和對象 E:\workspace\cargo-mongo\node_modules\bcrypt\build\Releas e\bcrypt_lib.exp bcrypt_lib.vcxproj -> E:\workspace\cargo-mongo\node_modules\bcrypt\build\Release\\bcrypt_lib.node Copying E:\workspace\cargo-mongo\node_modules\bcrypt\build\Release\/bcrypt_lib.node to E:/workspace/cargo-mongo/node_modules/bcrypt/lib/binding /napi-v3\bcrypt_lib.node 已復制 1 個文件。 > nodemon@1.19.4 postinstall E:\workspace\cargo-mongo\node_modules\nodemon > node bin/postinstall || exit 0 Love nodemon? You can now support the project via the open collective: > https://opencollective.com/nodemon/donate npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) + bcrypt@5.0.1 added 46 packages from 110 contributors and updated 411 packages in 100.985s 18 packages are looking for funding run `npm fund` for details
感覺本次可能是 管理員權限打開powershell 運行
npm install --global --production windows-build-tools
在起作用。但是其他的嘗試可能會在其他時候適用。