Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start React app fail on vscode by ESLint version

I have an issue that I cannot solve. I'm using ESLint in VSCode for my all projects. Now I created a new react app but when I run it (npm start or yarn start), it throws an error.

React app use ESLint 5.12.5, is lower version of mine. I tried following the steps in the suggestion but ... it's not fixed.

Can anyone solve my issue?

I tried npm uninstall -g eslint, npm uninstall eslint, npm i ...bla..bla, removed my ESLint extension in my VSCode, and re-created react app. But the error has not been fixed.
I checked eslint -v, it said 5.14.1, but in the error notice, vscode said version 5.16.0 is in node-modules @@.

This is full error notice when I try yarn start or npm start:

> [email protected] start E:\Extenal Code\Hoc JS\ReactJS-iViettech\homework02
> 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:

"eslint": "5.12.0"

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

E:\Extenal Code\Hoc JS\node_modules\eslint (version: 5.16.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.
That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
2. Delete node_modules in your project folder.
3. Remove "eslint" from dependencies and/or devDependencies in the package.json file in your project folder.
4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem.
If this has not helped, there are a few other things you can try:

5. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead.
This may help because npm has known issues with package hoisting which may get resolved in future versions.

6. Check if E:\Extenal Code\Hoc JS\node_modules\eslint is outside your project directory.
For example, you might have accidentally installed something in your home folder.

7. Try running npm ls eslint in your project folder.
This will tell you which other package (apart from the expected react-scripts) installed eslint.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project.
That would permanently disable this preflight check in case you want to proceed anyway.
like image 321
Đồng Vọng Avatar asked Apr 22 '19 02:04

Đồng Vọng


2 Answers

I just solved this issue, the error says: The react-scripts package provided by Create React App requires a dependency: "eslint": "5.12.0" (in my case "^5.16.0")

but also says you have another version at package.json that's E:\Extenal Code\Hoc JS\node_modules\eslint (version: 5.16.0) in my case was 6.1.0

so my solution was: I searched for the dependency called eslint and updated the version similar to Create React App expected "eslint": "^5.12.0" (in my case "eslint": "^5.16.0") at package.json Then run npm install and now you can run npm start... if you have troubles with slint-plugin-import just update the version as well, additional you can try installing locally instead of global with --save.

like image 176
DariusV Avatar answered Oct 13 '22 05:10

DariusV


I believe this is an ongoing issue with create-react-app and eslint as detailed at:

https://github.com/wesbos/eslint-config-wesbos/issues/17

There are a number of suggestions there, though I'm hoping they will put a more permanent fix in place.

like image 30
Concrete_Buddha Avatar answered Oct 13 '22 05:10

Concrete_Buddha