npm node gyp失敗怎麼辦

藏色散人
發布: 2022-12-29 14:42:01
原創
4063 人瀏覽過

npm node gyp失敗是因為「node-gyp.js」跟「Node.js」版本不匹配,其解決方法:1、透過「npm cache clean -f」清除node快取;2、透過「npm install -g n」安裝n模組;3、透過「n v12.21.0」指令安裝「node v12.21.0」版本即可。

npm node gyp失敗怎麼辦

本教學操作環境: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 1 gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp 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.0 gyp 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-sass gyp 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中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新問題
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!