error eslint@6.1.0: The engine "node" is incompatible with this module.

3,534 阅读1分钟

create-react-app新建项目时遇到的问题:

error eslint@6.1.0: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.12.0". 
Got "10.10.0"
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

问题的原因是node版本不兼容导致的,需要升级node版本,也可以不升级用npx命令解决:

用npx命令解决的方法:

$ npx create-react-app demo-app --use-npm

升级node版本(Mac):

1、查看本机node版本:

$ node -v

2、清除node的cache

$ sudo npm cache clean -f

3、安装 n 工具,n工具是用来管理node.js版本的

$ sudo npm install -g n

4、安装最新版的node

$ sudo n stable

5、更新npm版本

$ sudo npm install npm@latest -g

6、然后查看本机的node版本和npm版本

$ node -v
$ npm -v


7、创建react新项目:

$ create-react-app demo-app