After creating a react app with 'create-react-app' things have been successful till now. I have made a working react project. But now that I'm looking to implement unit testing with jest.
Using npm to install: 'npm install --save-dev jest' Then running: npm ls jest I notice that the react-script is looking for a jest version that is significantly older.
package.json:
"dependencies": {
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-redux": "^6.0.0",
"react-scripts": "2.1.5",
"redux": "^4.0.1"
},
"devDependencies": {
"jest": "^24.7.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
}
npm ls jest result:
+-- [email protected]
`-- [email protected]
`-- [email protected]
npm start error:
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:
"jest": "23.6.0"
Don't try to install it manually: your package manager does it
automatically.
However, a different version of jest was detected higher up in the tree:
C:\Users\userName\sample js codes\redux\songs\node_modules\jest (version:
24.7.1)
Is there a solution to solve this dependency version issue?
After creating a react app with 'create-react-app' things have been successful till now. I have made a working react project. But now that I'm looking to implement unit testing with jest.
Using npm to install: 'npm install --save-dev jest' Then running: npm ls jest I notice that the react-script is looking for a jest version that is significantly older.
package.json:
"dependencies": {
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-redux": "^6.0.0",
"react-scripts": "2.1.5",
"redux": "^4.0.1"
},
"devDependencies": {
"jest": "^24.7.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "jest",
"eject": "react-scripts eject"
}
npm ls jest result:
+-- [email protected]
`-- [email protected]
`-- [email protected]
npm start error:
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:
"jest": "23.6.0"
Don't try to install it manually: your package manager does it
automatically.
However, a different version of jest was detected higher up in the tree:
C:\Users\userName\sample js codes\redux\songs\node_modules\jest (version:
24.7.1)
Is there a solution to solve this dependency version issue?
Share Improve this question asked Apr 11, 2019 at 10:56 kevin mankevin man 2973 silver badges12 bronze badges 2- As far as I know, create-react-app es with Jest built-in, no need to install it additionally. You have a version conflict now because you installed it additionally. Revert the package.json, that should fix it – Patrick Hund Commented Apr 11, 2019 at 11:24
- 1 You are absolutely correct. You are a wizard, Harry! – kevin man Commented Apr 11, 2019 at 12:35
1 Answer
Reset to default 6Create-react-app es with Jest built-in, there is no need to install it additionally.
You have a version conflict now because you installed it additionally. To fix it, revert your changes to package.json.