'Need help on a react.js error that I keep on getting
Every time I try running npm start on a new project I keep on getting this error. Does anyone know or have any idea how to fix this??
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:
"babel-jest": "^26.6.0"
Don't try to install it manually: your package manager does it automatically. However, a different version of babel-jest was detected higher up in the tree:
D:\node_modules\babel-jest (version: 24.9.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:
- Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
- Delete node_modules in your project folder.
- Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
- 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:
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.
Check if D:\node_modules\babel-jest is outside your project directory. For example, you might have accidentally installed something in your home folder.
Try running npm ls babel-jest in your project folder. This will tell you which other package (apart from the expected react-scripts) installed babel-jest.
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!
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start:
react-scripts start
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\smaso\AppData\Roaming\npm-cache_logs\2021-01-26T22_50_48_484Z-debug.log
Solution 1:[1]
I also face this problem. Simple solution of this problem is: 1)create .env file. 2) add SKIP_PREFLIGHT_CHECK=true in the file. 3) npm start
Solution 2:[2]
If this fails to work, create a .env file in the root directory of your project and add the following line
SKIP_PREFLIGHT_CHECK=true
Solution 3:[3]
just go to your project's root directory and delete node_module folder and npm start your project.
Solution 4:[4]
Delete and redownload node modules and run application again
Solution 5:[5]
To fix the dependency tree, try following the steps below in the exact order:
- Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
- Delete node_modules in your project folder.
- Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
- 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:
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.
Check if ./babel-jest is outside your project directory. For example, you might have accidentally installed something in your home folder.
Try running npm ls babel-jest in your project folder. This will tell you which other package (apart from the expected react-scripts) installed babel-jest.
Solution 6:[6]
Seems like you created the react project using create-react-app and installed jest using the following command.
yarn add --dev jest babel-jest @babel/preset-env @babel/preset-react react-test-renderer
But in the documentation it says just to run the following command if you are using create-react-app
yarn add --dev react-test-renderer
[See the documentation][1]https://jestjs.io/docs/tutorial-react
This worked for me.
Solution 7:[7]
I used the following command to uninstall jest npm uninstall jest in the root project folder (not the client) and then used the react scripts start command npm start and it worked
Solution 8:[8]
removing jest.config.js
and uninstall ts-jest
solved my problem
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | vikky singh |
Solution 2 | Slava Rozhnev |
Solution 3 | sonali |
Solution 4 | Agha Shayan |
Solution 5 | S.Kihara |
Solution 6 | Sahan Nimesh |
Solution 7 | Deborah |
Solution 8 | tylim |