I was trying to create a new project to follow a course, but creating the project with npx create-react-app my_app
created everything with React 18 version and its corresponding scripts for that version.
How can I choose the version of React I want to install?
React version 18 is now stable and ready to be released into production for new projects. It has been tested for more than a year. It is not recommended to use an old version for new projects.
However, it is possible to do it in the following way:
npx create-react-app my_app
.package.json
and change the version ofreact
,react-dom
, andreact-scripts
to the previous version, or to the version you want to install:package-lock.json
andnode_modules
npm install
in the project folder.On installation, you'll see a few Package Warnings
deprecated
, but it's totally normal since you're using an old version.Following these steps you should be able to get your app up and running with react 17 without problem. For reference check create-react-app (specific / older react version) .