(資料圖片僅供參考)
本教程操作環境:Windows10系統、node v12.21.0版、Dell G3電腦。
npm node gyp失敗怎么辦?
npm install報node-gyp相關錯誤
我在構建一個vue項目時,報了node-gyp構建相關錯誤,錯誤信息如下
1 error generated.make: *** [Release/obj.target/binding/src/binding.o] Error 1gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2gyp ERR! stack at ChildProcess.onExit (/Users/xingxin/code_sxf2/nft-server/nft-ui/node_modules/node-gyp/lib/build.js:262:23)gyp ERR! stack at ChildProcess.emit (node:events:527:28)gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)gyp ERR! System Darwin 20.4.0gyp ERR! command "/usr/local/bin/node" "/Users/xingxin/code_sxf2/nft-server/nft-ui/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="gyp ERR! cwd /Users/xingxin/code_sxf2/nft-server/nft-ui/node_modules/node-sassgyp ERR! node -v v16.15.1
經過各種嘗試才發現
原因是node-gyp.js跟我的Node.js版本不匹配,我的Node版本太高了
經過嘗試發現Node降級到 v12.21.0版本后,構建成功。
降級操作相關命令:
# 查看當前node版本node –v# 清除node緩存npm cache clean -f# 安裝n模塊npm install -g n# 安裝v12.21.0版本n v12.21.0# 查看當前node版本node –v
推薦學習:《node.js視頻教程》
以上就是npm node gyp失敗怎么辦的詳細內容,更多請關注php中文網其它相關文章!
關鍵詞: node