-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set React version to react@17 when i use npx create-react-app ? #12269
Comments
You can set dependencies > "react-dom": "^18.0.0" to "react-dom": "^17.0.0" or you can reinstall react with @17 version. |
I created a cra templte, and used mobx, mobx can not work with react@18 yet, when I use
so I need to lock the react with @17. Good news is I got a solution, add |
For some additional context on what I see
|
Similar results were obtained with
|
Getting the same error |
Looks like this is the issue testing-library/react-testing-library#1041 |
Getting the exactly same error as AkifumiSato. |
forgot to mention, you can change to react 17 by deleting node_modules and package-lock.json, then on package.json change "react": "^18.0.0" and "react-dom": "^18.0.0" to "react": "^17.0.2" and "react-dom": "^17.0.2" or the version that you want, then run "npm install" |
Yes, manually changing the "react" and "react-dom" version and then npm install works for me. Thanks. |
Testing Library React 12.x only works with React < 18 Make sure that these versions match. If there are still issues then please provide a minimal, cloneable repository that I can check out. |
This issue exists more broadly for any dependencies that are not yet ready to use React 18. (I'm having this issue because we have an internal library that isn't able to work with v18 yet) -- From what I can see, there is no way to use an old version of create-react-app anymore because it disallows use of global CRA with npx. We can't specify preferred CRA version, can't specify preferred react version without manually changing things after generating the app. Why is it so locked down? Am I missing something? |
Having the same issue. Unable to downgrade from v18 to v17 due to dependency errors. |
You dont need to delete node modules really. just change the version of react on your packagejson to the version you want and run npm i . This will upgrade or downgrade your version based on what you put on your packagejson |
You can still use old version but install the new version and then downgrade |
Installnpx create-react-app my_app --template typescript
|
Check this, its working |
FTR, The comment above is a good manual workaround. There are a few more libraries you might want to downgrade in your CRA initialized app.
But the OP was asking a question about setting alternative React versions when authoring a CRA template. Turns out this is possible by simply including the React dependencies in the template's package.json. By default, CRA will install the latest React libraries, but if the template specifies the React dependencies explicitly those will override the defaults. For example, Fluent UI's CRA template uses this pattern. |
Why isn't this fixed in a simple manner? Should be some sort of |
i can |
I tried running the following command. But, the answer to it was informed in the output of the command which, in turn, did not create the application.
|
+1 |
What worked for me is. Install
change these @testing dependencies to the version below
and react to version
Save. Delete change index.tsx from folder app/index.tsx
run
|
I create a cra templte, but it does not work with react@18 yet, how to set the defautl react version to react@17?
The text was updated successfully, but these errors were encountered: