gyp: Undefined variable module_name in binding.gyp while trying to load binding.gyp
作者:互联网
npm i bcrypt
新系统拉取项目,下载依赖包,其中包含 bcrypt 依赖,一直安装不成功。
已安装号 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
在起作用。但是其他的尝试可能会在其他时候适用。
标签:load,node,ERR,modules,binding,npm,gyp,bcrypt 来源: https://www.cnblogs.com/jiayouba/p/15436827.html