[英]Cannot npm install due to node-gyp: binding.gyp not found
我整天都在做这件事,并尝试了很多不同的事情:
--msvs_version=
标志设置为2010, 2011, 2012, 2013, 2015
python=C:\Python27\python.exe
npm -g install npm@next
node-gyp rebuild
和node-gyp configure
艰难时期。
该软件包是一个 Electron/React 应用程序,我正在运行 Windows 10。 npm install
的控制台输出是
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\x64\Microsoft.Cpp.x64.Targets(514,5): error MSB8008: Specif ied platform toolset (v120) is not installed or invalid. Please make sure that a supported PlatformToolset value is sel ected. [C:\Users\scheinerbock\Desktop\mpstudio\node_modules\mplib\build\addon.vcxproj] gyp ERR! build error gyp ERR! stack Error: `msbuild` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Users\scheinerbock\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 10.0.14393 gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\scheinerbock\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\scheinerbock\Desktop\mpstudio\node_modules\mplib gyp ERR! node -v v6.10.0 gyp ERR! node-gyp -v v3.5.0 gyp ERR! not ok
对于node-gyp rebuild
:
gyp: binding.gyp not found (cwd: C:\Users\scheinerbock\Desktop\mpstudio) 尝试加载 binding.gyp
我已经离开了我的驾驶室,除了解决方案之外,我将不胜感激任何建议或信息。
我正在使用 macos catalina 10.15.5,我遇到了同样的问题,上述所有解决方案都对我不起作用。 我能够通过运行来解决这个问题
npm i -g node-gyp@latest && npm config set node_gyp "/usr/local/lib/node_modules/node-gyp/bin/node-gyp.js"
希望这对人们有所帮助。
创建一个binding.gyp文件并将其放在您的项目根目录中。 该文件的内容如下所示:
{
"targets": [
{
"target_name": "binding",
"sources": [ "src/binding.cc" ]
}
]
}
binding.gyp
文件以类似 JSON 的格式描述构建模块的配置。 该文件与 package.json 一起放置在包的根目录中。 见这里: https ://github.com/nodejs/node-gyp#the-bindinggyp-file
确保您安装了 python 2.x 版本而不是 3.x 对我来说,它在我安装 python 2.6 后工作
尝试了这么多解决方案,这个似乎对我立即起作用。 使用命令“apt install make g++”安装 g++ 和 cmake,对于 Windows,我相信这些有他们的网站可供下载。
https://cmake.org/download/ - for make
| https://sourceware.org/cygwin/ - for g++
(如果不是在谷歌上搜索 gcc)
我还没有在 Windows 上测试过这个,这对我在 Linux 上的 apt 命令有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.