Afaq Ahmed Khan
Afaq Ahmed Khan

Reputation: 2302

react-scripts babel scripts error running with yarn on local react application

Facing this issue after running yarn, trying to run my repo, this is my repo structure

enter image description here

I run command yarn and this happens

yarn yarn install v1.17.3 [1/4] Resolving packages... [2/4] Fetching packages... info [email protected]: The platform "win32" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. info [email protected]: The platform "win32" is incompatible with this module. info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning "antd > [email protected]" has unmet peer dependency "dayjs@^1.8.18". warning "react-scripts-rewired > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0". warning "react-scripts-rewired > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0". warning "react-scripts-rewired > [email protected]" has incorrect peer dependency "@typescript-eslint/[email protected]". warning "react-scripts-rewired > [email protected]" has incorrect peer dependency "@typescript-eslint/[email protected]". warning "react-scripts-rewired > @typescript-eslint/eslint-plugin > [email protected]" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta". warning " > [email protected]" has unmet peer dependency "eslint@^5.16.0 || ^6.8.0". warning " > [email protected]" has unmet peer dependency "eslint-plugin-react@^7.19.0".
warning " > [email protected]" has unmet peer dependency "eslint-plugin-react-hooks@^2.5.0 || ^1.7.0". warning "eslint-config-airbnb > [email protected]" has unmet peer dependency "eslint@^5.16.0 || ^6.8.0". warning " > [email protected]" has unmet peer dependency "[email protected] - 6.x". [4/4] Building fresh packages... success Saved lockfile. Done in 166.99s. PS D:\Repos\pth\telehealth-frontend> yarn start yarn run v1.17.3 $ npm run build-css && react-scripts start

[email protected] build-css D:\Repos\pth\telehealth-frontend node-sass-chokidar src/styles/App.scss -o src/styles

Rendering Complete, saving .css file... Wrote CSS to D:\Repos\pth\telehealth-frontend\src\styles\App.css

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-rewired package provided by Create React App requires a dependency:

"babel-eslint": "10.0.2"

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

D:\node_modules\babel-eslint (version: 9.0.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 "babel-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:

  1. 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.

  2. Check if D:\node_modules\babel-eslint is outside your project directory. For example, you might have accidentally installed something in your home folder.

  3. Try running npm ls babel-eslint in your project folder. This will tell you which other package (apart from the expected react-scripts-rewired) installed babel-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.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Any help is appreciated

Upvotes: 0

Views: 2427

Answers (1)

Sagar More
Sagar More

Reputation: 476

The error is because you have manually installed babel-eslint of version 9.0.0 but react-scripts require babel-eslint of version 10.0.2.

You have to run yarn remove babel-eslint and then run yarn install

This will install all the required dependencies from your package.json

Upvotes: 0

Related Questions