我一整天都在研究这个问题,并尝试了很多不同的事情:
--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 时未找到 Binding.gyp(cwd:C:\Users\scheinerbock\Desktop\mpstudio)
我已经超出了我的掌控能力,除了解决方案之外,我还希望得到任何建议或信息。
我正在使用 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 后就起作用了
尝试了很多解决方案,这个似乎立即对我有用。 安装 g++ 和 cmake,使用命令“apt install make g++”,对于 Windows,我相信这些有他们的网站可供下载。
https://cmake.org/download/ - for make
|
https://sourceware.org/cygwin/ - for g++
(如果没有在谷歌上搜索gcc)
我还没有在 Windows 上测试过这个,这对我在 Linux 上使用 apt 命令有用。
如果您在
NVM
上使用 Windows
,您可以执行以下操作:
在您的家庭用户中创建以下文件 ->
binding.gyp
c:/users/my-user/binding.gyp
然后这将是内容(在本例中我的节点版本是14.21.2,但您可以将其替换为您当前的版本。)
{
"targets": [{
"target_name": "binding",
"sources": [ "C:/ProgramData/nvm/v14.21.2" ]
}]
}
就其价值而言,我的问题是节点不兼容的次要版本,npm 没有通知我
我使用了yarn,它显示了实际的问题,而不是在整个控制台上吐出同样的错误。
纱线向我展示:
error [email protected]: The engine "node" is incompatible with this module. Expected version "^14.18.0 || >=16.10.0". Got "14.17.0"
error Found incompatible module.
我的案例的实际解决方案是
nvm use 16
经验教训:不要相信 npm