Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create React App requires a dependency: "babel-loader": "8.1.0"

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 locall y.

The react-scripts package provided by Create React App requires a dependency:

"babel-loader": "8.1.0"

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

D:\Reactjs\node_modules\babel-loader (version: 8.0.6)

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 .e nv 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 proje ct folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-loader" from dependencies and/or devDependencies in the packa ge.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 st eps 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:\Reactjs\node_modules\babel-loader is outside your project direc tory. For example, you might have accidentally installed something in your home f older.

  3. Try running npm ls babel-loader in your project folder. This will tell you which other package (apart from the expected react-scrip ts) installed babel-loader.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your pro ject. That would permanently disable this preflight check in case you want to proceed anyway.

like image 470
RANJAN KUMAR JHA Avatar asked Apr 01 '20 06:04

RANJAN KUMAR JHA


3 Answers

Just add an optional dep in your package.json:

"optionalDependencies": {
  "babel-loader": "8.1.0"
},

...and run npm i or yarn again.

like image 63
Nickon Avatar answered Sep 23 '22 06:09

Nickon


Please if you haven't already, try the troubleshooting guide. If that fails too create a .env file in your root directory add SKIP_PREFLIGHT_CHECK=true and relaunch with npm start. If that doesn't help either just use yarn instead. It should work. For most people deleting the node_modules folder and reinstalling solves the issue.

npm i yarn -g

like image 10
Tumi-D Avatar answered Oct 12 '22 20:10

Tumi-D


You may have previously installed a project in your user folder. Check for a node_modules directory and package-lock.json in your user root.

You can remove them using:

rm -rf ~/User/node_modules
rm -rf ~/User/package-lock.json

After that delete node_module directory and pack-lock.json file in your project, and run npm install again. Then it should work.

like image 8
Yesith Avatar answered Oct 12 '22 18:10

Yesith