安装npm包时出现错误 npm ERR! code ELIFECYCLE

4
我不知道发生了什么,但是我在进行操作时收到了以下错误提示:
>npx create-react-app .
>npm i <packages>
>npm install 

等等,并没有一个上面的命令有效,所以以上命令都无法使用。

这是错误信息:

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn C:\Program Files\git\bin\bash.exe
npm ERR! file C:\Program Files\git\bin\bash.exe
npm ERR! path C:\Program Files\git\bin\bash.exe
npm ERR! errno ENOENT
npm ERR! core-js@2.6.11 postinstall: `node -e "try{require('./postinstall')}catch(e){}"`
npm ERR! spawn C:\Program Files\git\bin\bash.exe ENOENT
npm ERR! 
npm ERR! Failed at the core-js@2.6.11 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

我发现这主要是Windows的问题,但我使用Mac。

2个回答

6

以管理员身份打开CMD,然后运行:

npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接