bash - 安装 npm 包时出错 npm ERR!代码生命周期

标签 bash npm npm-install npm-start

不知道发生了什么,但我收到以下错误

>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

最佳答案

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

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

关于bash - 安装 npm 包时出错 npm ERR!代码生命周期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62517815/

相关文章:

java - 无法在 Catalina 上设置 JAVA_HOME

linux - bash 脚本中的一个特定命令在由 cron 运行时不起作用,所有其他命令都可以

node.js - 找不到在 docker compose 环境中运行的 Node js 应用程序的模块

通过 github 发布的 npm 包未出现在 npm 模块搜索中

javascript - 当有人安装我的 npm 模块时,如何告诉 npm 不要安装任何依赖项?

macos - 如何使 zsh 在 Mac OS X 上作为登录 shell 运行(在 iTerm 中)?

javascript - 无法理解 Node.js walker

node.js - NPM :Cannot find module 'bcrypt'

css - 全局安装时无法在 React-app 中包含 Bootstrap

linux - 通过shell脚本更改文本文件中的路径地址