初始化React项目报错

1,403 阅读1分钟

1,脚手架安装

npm install -g create-react-app

2,react项目创建

create-react-app reactdemo

3,初始化项目报错:错误提示

error eslint@6.8.0: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1". Got "10.12.0"
error Found incompatible module

只要是因为node 版本支持 这是node版本不兼容导致的,升级node版本可以解决,不升级也可以解决,用下面的命令

npx create-react-app my-app  --use-npm

为什么会用npx:

npx相当于 执行的命令: 首先安装脚手架: npm install -g create-react-app
                    然后创建项目: create-react-app reactdemo
                    然后删除脚手架工具: delete create-react-app

npx不用考虑ndoe ,npm的版本