簡體   English   中英

安裝 npm 時,節點 gyp 重建在 Mac OS High Sierra 上失敗

[英]node-gyp rebuild fails on Mac OS High Sierra while npm install

我在終端中遇到以下錯誤,同時它嘗試安裝“node-expat”包之一。 我曾嘗試使用 nvm 切換到不同的節點版本,但仍然因相同的錯誤而失敗。

gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/node-expat
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! node-expat@2.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.0.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-expat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     c:\<redacted>\npm-debug.log

我繼續按照git hub頁面上的建議在我的機器上安裝x-code,然后出現以下錯誤。 不確定如何進一步調試。

xcode-select: error: tool 'xcodebuild' requires Xcode, 
but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

我剛把它固定在我的機器和我同事的機器上。

按照以下步驟在 MacOS highSierra 10.13 上修復它:

  1. 下載 xcode 的命令行工具 (MacOS 10.13) 並安裝它。 從“ https://developer.apple.com/download/more/ ”下載
  2. 從應用商店安裝了 xcode 10.0。 打開 xcode 並完成 xcode 在初始啟動時所做的常規配置。
  3. 在此之后,它開始給出“xcode-select”路徑問題,如上面的描述中所述。 在運行命令“ xcode-select --print-path ”時,它顯示路徑為“/Library/Developer/CommandLineTools”,所以我繼續嘗試“ xcode-select --reset ”,之后路徑更改為“ /Applications” /Xcode.app/Contents/Developer ”。 在它之后,構建立即開始工作,沒有任何問題。

Luke 上面提到的解決方案部分對我有用(MacOS),但產生了另一個問題: gyp ERR! stack Error: gyp ERR! stack Error: make failed with exit code: 2已通過刪除鎖定的 json 文件解決。 問題是由於 MAC OS 中的許可而產生的。 因此,如果您已經重新安裝了 xcode,請打開終端(命令行)並鍵入:

xcode-select --reset

然后轉到您的項目文件夾並刪除: package-lock.json現在在終端中重新安裝項目:

npm install

我希望這可以幫助別人!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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