Npm is installed on my machine using MacOS, and I'm getting an ELIFECYCLE
error with following additional hints after I've run npm run start
or npm start
.
There might be a problem with the project dependency tree.
[0] It is likely not a bug in Create React App, but something you need to fix locally.
[0]
[0] The react-scripts package provided by Create React App requires a dependency:
[0]
[0] "babel-loader": "8.0.6"
[0]
[0] Don't try to install it manually: your package manager does it automatically.
[0] However, a different version of babel-loader was detected higher up in the tree:
[0]
[0] /Users/user1/node_modules/babel-loader (version: 8.1.0)
[0]
[0] Manually installing incompatible versions is known to cause hard-to-debug issues.
In case it was a Babel-Loader issue I removed it, and after that when I run:
npm ls babel-loader
It is coming up as still there, returning this:
[email protected]
└── [email protected]
Babel-loader is not listed in the package.json file. I'm really not sure how to uninstall babel-loader completely, and if I did not sure if I would have to reinstall it again.
You have two possible approaches depending on what the root cause is. The default answer is to delete your lock file and node_modules folder, and regenerate the lock file.
$ rm package-lock.json # or `rm yarn.lock`
$ rm -rf node_modules/
$ npm install # or `yarn install`
This doesn't always work. In case the issue persists, then do the following.
$ npm ls babel-loader # or `yarn list babel-loader`
warning Lockfile has incorrect entry for "babel-loader@^<bad-version>". Ignoring it.
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ babel-loader@<bad-version>
└─ [email protected]
└─ babel-loader@<good-version>
✨ Done in 1.17s.
Once you've done that, open your package.json
and add the following:
{
// ...
"resolutions": {
"babel-loader": "<good-version>"
}
}