首页 > 解决方案 > 在 node-expat@2.3.17 安装脚本失败 - 任何 NPM 安装都会发生

问题描述

我尝试安装的任何 npm 包,甚至只是 npm install 本身都会给我以下错误。

fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [Release/obj.target/node_expat/node-expat.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/myname/.npm-global/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:257:12)
gyp ERR! System Darwin 18.5.0
gyp ERR! command "/Users/myname/.npm-global/lib/node_modules/node/bin/node" "/Users/name/.npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/myname/Desktop/Portfolio/portfolio/node_modules/node-expat
gyp ERR! node -v v12.2.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-expat@2.3.17 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.3.17 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我已经尝试在我的主目录中删除我的 node-gyp 文件,从我的项目和 json 锁定文件中删除我的 node_modules 文件夹。我还尝试卸载 npm 并重新安装它以及重新启动我的 mac。

标签: node.jsnpmnode-gyp

解决方案


您可以在此处查看拉取请求:https ://github.com/astro/node-expat/pull/196 。我认为您使用的是 Node 12。您可以将 Node 版本降级到 10 或 8。可能会出现一些警告,但您可以安装 node-expat 成功。可能对你有用。


推荐阅读