• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

npm node gyp失败怎么办

武飞扬头像
PHP中文网
帮助85

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失败怎么办?

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

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tangbigkh
系列文章
更多 icon
同类精品
更多 icon
继续加载