SUJIT JAIWALIYA
SUJIT JAIWALIYA

Reputation: 31

Error while npm run build? eslint package error

npm start

[email protected] 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:

"eslint": "^7.11.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:

/Users/sujit_jaiwaliya/node_modules/eslint (version: 6.8.0)

Upvotes: 3

Views: 9447

Answers (3)

Wylie
Wylie

Reputation: 550

I started the project with the right versions of everything but somewhere my code broke and started requesting a different version of eslint. "react-scripts" was the only package that had eslint as a dependency.

I tried npm uninstall eslint but it didn't quite work. So I removed react-scripts and then reinstalled it as below

  1. npm uninstall react-scripts
  2. npm install react-scripts.

You might want to install the specific version that was installed before. If your current version is 4.0.3 then when installing just add it at the end like this npm install [email protected] on step 2 above.

It totally removed the error for me, hope it does for you too.

Upvotes: 0

MELLAL Fethi
MELLAL Fethi

Reputation: 147

SOLUTION: This worked for me I hope it does the same to you guys:

  1. I Unistall eslint version 6.8.0 :

    npm uninstall [email protected]

  2. Then I install [email protected]:

    npm i [email protected]

  3. Then i run fix audit:

    npm audit fix --force

  4. Then i changed the DIR file by adding a .env file with this code in it :

    ESLINT_NO_DEV_ERRORS=true

This issue has been fixed in the react-scipts:"4.0.3" but, the eslint errors present in the project are not converted to warnings by default. You have to create an .env file that should contain a ESLINT_NO_DEV_ERRORS=true flag. Due to this flag, you will receive the eslint errors as warnings and not as errors in the development.

This flag is ignored during production and when they are any git hooks running, which will, in turn, cause an error when you are trying to commit the code with an eslint error in it.

Upvotes: 9

Damodar Hegde
Damodar Hegde

Reputation: 468

This is because you already have some other version of eslint installed. To resolve this, first remove that version (in this case 6.8.0) and then again run

npm start

Uninstall the other version using npm uninstall eslint

Upvotes: 1

Related Questions