0

I am learning react from an old tutorial, so I have to create a project with the version 1.5.2 of Create React App. I have installed create-react-app@1.5.2 globally with no problems. After I executed npx create-react-app it uses the latest version of Create React App.

Is there any way that I could do it, or where can I find the code for a project with that version?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Zaki
  • 11
  • 1
  • 4

2 Answers2

0

It's no possible because of several reasons:

I installed the package "create-react-app@1.5.2" from here to assure I'm using the correct create-react-app version:

npm init -y
npm install create-react-app@1.5.2
    
or 

yarn init -y
yarn add create-react-app@1.5.2

In the \node_modules\create-react-app folder I executed the command:

node index.js app-folder

And it installed the last version of react without a template because it's an old version of the package, but still the latest version:

enter image description here

Checking the file createReactApp.js I can see it's meant to be that way, even if it's an old version of the builder "create-react-app" it will install the last version of the packages.

Also, if you try this command: node index.js app-folder --scripts-version 1.5.2

It will not found the version you want, instead, it will show a list of available versions of react-scripts.

enter image description here

According to the date, the correct packages are:

react: 16.4.2 react-dom: 16.4.2 react-scripts: 1.1.5

So you can install the version you want with this:

npm init -y
npm install react@16.4.2 react-dom@16.4.2 react-scripts@1.1.5

or

yarn init -y
yarn add react@16.4.2 react-dom@16.4.2 react-scripts@1.1.5
0

If you're react v18, and you want to go down to the previous non-change breaking version, here's what you can do:

In your package.json replace:

"react": "^18.0.0"
"react-dom": "^18.0.0"

With

"react": "^17.0.2"
"react-dom": "^17.0.2"

Then go to your entry file index.js At the top, replace:

import ReactDOM from 'react-dom/client'

With

import ReactDOM from 'react-dom';

In your index.js file, replace:

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>
);

With

ReactDOM.render(
 <React.StrictMode>
   <App />
 </React.StrictMode>,
 document.getElementById('root')
);
  • Delete your node_modules and run yarn install or npm i --force
  • After installation, run yarn start or npm start

--------------------------------------OR------------------------

If you want through npx command

npx create-react-app[version] my-app 
npx create-react-app@17.0.2 my-app 
Deepak Singh
  • 749
  • 4
  • 16