使用Yarn运行npm脚本时遭遇ERR spawn EINVAL错误求助
运行包含Yarn的npm脚本时出现"ERR spawn EINVAL"错误
问题重现步骤
- 使用create-react-app初始化项目
- 在package.json中添加如下脚本:
"scripts": { "lint": "yarn add -D prettier && yarn add -D babel-eslint && npx install-peerdeps --dev eslint-config-airbnb && yarn add -D eslint-config-prettier eslint-plugin-prettier" }
- 执行
npm run lint,系统询问是否使用Yarn,输入"y"确认 - 随后抛出错误:
ERR spawn EINVAL
已尝试的解决方法
- 全局安装Yarn:
npm install -g yarn - 检查配置与环境变量,未发现异常
环境信息
- 操作系统:Windows 11
- Node版本:
> node --version v20.12.2
- npm版本:
> npm --v 10.5.0
- Yarn版本:
> yarn --v yarn install v1.22.22
内容的提问来源于stack exchange,提问作者Pritam Ghosh
相关产品推荐
相关产品推荐

