react脚手架构建运行时报错问题

具体操作

sudo npm install -g create-react-app
mkdir react-first-demo
cd react-first-demo
create-react-app react-cli
cd react-cli
npm install (依赖安装完以后执行npm start)
npm start

错误

$ react-scripts start

There might be a problem with the project dependency tree.
It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

“webpack”: “4.29.6”

Don’t try to install it manually: your package manager does it automatically.
However, a different version of webpack was detected higher up in the tree:

/Users/mac/Desktop/node_modules/webpack (version: 3.8.0)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.

解决方法

在react-cli项目里面添加.env文件,文件中添加SKIP_PREFLIGHT_CHECK=true,在运行npm start。错误提示里又说这样可以解决目前问题,可能还会出现其他问题,暂时没遇到,有问题可以交流,或者有什么更好的方法。

结果

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值