'Downgrade React v17 to v18 created using npx
How can I downgrade project created with "npx create-react-app . --template typescript". All posts I find online suggest manually changing dependencies then to run "npm install" but there's always some error when I do that. How can I modify dependencies to make it work with react v17 ?
here's my attempt to downgrade :
"dependencies": {
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.2.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.1",
"@types/node": "^16.11.36",
"@types/react": "^17.0.2",
"@types/react-dom": "^17.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.1",
"typescript": "^4.6.4",
"web-vitals": "^2.1.4"
}
and here is errors:
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN react@"^17.0.2" from the root project
npm WARN 3 more (@testing-library/react, react-dom, react-scripts)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^18.0.0" from @testing-library/[email protected]
npm WARN node_modules/@testing-library/react
npm WARN @testing-library/react@"^13.2.0" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN react@"^17.0.2" from the root project
npm WARN 3 more (@testing-library/react, react-dom, react-scripts)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"^18.1.0" from [email protected]
npm WARN node_modules/react-dom
npm WARN react-dom@"^17.0.2" from the root project
npm WARN 1 more (@testing-library/react)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react-dom
npm WARN react-dom@"^17.0.2" from the root project
npm WARN 1 more (@testing-library/react)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react-dom@"^18.0.0" from @testing-library/[email protected]
npm WARN node_modules/@testing-library/react
npm WARN @testing-library/react@"^13.2.0" from the root project
Solution 1:[1]
You could always run
npm resolve dependencies
Manually downgrading might throw some warning tell you that there are newer version than the one you are using now but its still work all the same.
And you made a mistake in your package.json
"react-scripts": "5.0.1",
Make it
"react-scripts": "^5.0.1",
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 | awesome webber |
