簡體   English   中英

由於 node-gyp 無法安裝 npm:binding.gyp not found

[英]Cannot npm install due to node-gyp: binding.gyp not found

我整天都在做這件事,並嘗試了很多不同的事情:

  • 卸載節點並安裝最新版本
  • 使用--msvs_version=標志設置為2010, 2011, 2012, 2013, 2015
  • 刪除 .node-gyp 文件夾
  • 像這樣將 python 路徑添加到 .npmrc: python=C:\Python27\python.exe
  • npm -g install npm@next
  • 運行node-gyp rebuildnode-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

看到這個線程,也許它有幫助。

node-gyp 使用 Visual Studio 在 Windows 上構建,所以我猜這個問題來自你的 VS 安裝。

從這個路徑(C:\Program Files (x86)\MSBuild)來看,看起來它需要更新的版本(可能是首次引入MSBuild的 Visual Studio 2015)。

嘗試將 npm 版本降級到 v6:

npm install -g npm@6 

或將節點版本降級到 v12 一起使用nvm

參考: https ://github.com/nodejs/node-gyp/issues/508

確保您安裝了 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM