facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.69k stars 26.84k forks source link

Not able to use create-react-app 4.0.3 #12282

Open gitpushdashf opened 2 years ago

gitpushdashf commented 2 years ago

From a node:17-alpine Docker image:

/ # npx create-react-app@4.0.3 test
Need to install the following packages:
  create-react-app@4.0.3
Ok to proceed? (y) y
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.1).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/

npm notice
npm notice New minor version of npm available! 8.5.5 -> 8.6.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.6.0
npm notice Run npm install -g npm@8.6.0 to update!
npm notice

It would be very handy to be able to use 4.0.3 while 5.0.X issues are worked out.

al-amiir commented 2 years ago

I had the same issue, the solution that worked for me is to clear the cache

npm cache clean --force  

but wait for it to clear, the clearing process will not show you a loading bar of cleaning, so you may think it is not responding and ( ctr c ) the process, I was doing that, Then try again

npx create-react-app projectName  

If still not working try

npx clear-npx-cache

then

npm cache clean --force  
gitpushdashf commented 2 years ago

That may well solve some issues, but I don't think it's the one here. I'm standing up fresh Docker containers (so no NPM cache) and am getting an error message trying to run CRA 4.0.3, where older versions of CRA are explicitly blocked.

testacode commented 2 years ago

Me too, I was trying to use latest CRA but storybook and other libraries don't work with react 18 yet so when trying to use CRA4 got the same error, I have cleaned all npx, yarn and npm caches and also uninstalled any global dependency and still doesn't work. Please help!

testacode commented 2 years ago

I had the same issue, the solution that worked for me is to clear the cache

npm cache clean --force  

but wait for it to clear, the clearing process will not show you a loading bar of cleaning, so you may think it is not responding and ( ctr c ) the process, I was doing that, Then try again

npx create-react-app projectName  

If still not working try

npx clear-npx-cache

then

npm cache clean --force  

This just installs the latest version which comes with latest react version (18), not suitable for me. I need version 17.

dsv-sergey commented 2 years ago

I had the same issue, the solution that worked for me is to clear the cache

npm cache clean --force  

but wait for it to clear, the clearing process will not show you a loading bar of cleaning, so you may think it is not responding and ( ctr c ) the process, I was doing that, Then try again

npx create-react-app projectName  

If still not working try

npx clear-npx-cache

then

npm cache clean --force  

This just installs the latest version which comes with latest react version (18), not suitable for me. I need version 17.

We created a custom template that needs react version 17, but CRA does not provide mechanisms to fix react and react-dom versions

JRebella commented 2 years ago

I tried using CRA4 with

npx create-react-app@4.0.3 test-CRA

but that simply gives this error

You are running `create-react-app` 4.0.3, which is behind the latest release 
(5.0.1).

We no longer support global installation of Create React App.

I don't understand why they try so hard to not allow you to use an old version. Tons of use cases and people need React 17 instead of React 18. And making a fresh app with CRA4 is much more stable than making one with CRA5 and downgrading React versions manually

hsbtr commented 1 year ago

I tried using CRA4 with

npx create-react-app@4.0.3 test-CRA

but that simply gives this error

You are running `create-react-app` 4.0.3, which is behind the latest release 
(5.0.1).

We no longer support global installation of Create React App.

I don't understand why they try so hard to not allow you to use an old version. Tons of use cases and people need React 17 instead of React 18. And making a fresh app with CRA4 is much more stable than making one with CRA5 and downgrading React versions manually

In another answer, I saw that using yarn create react-app new-app --template typescript --scripts-version 4.0.3 can install the specified version of react-scripts, but cannot specify the react version

richardkmichael commented 1 year ago

I want to install version 4.0.3 because that's the version in use by our large app. I want to install the exact same version in a new, bare project to experiment with our create-react-app configuration.

I've tried the npx clear-npx-cache suggestion in the diff of #12891 , but it didn't help.

The npx cache is empty: ls -la ~/.npm/_npx # => empty

The easiest way to run an old version of create-react-app is to install the desired version (npm install create-react-app@4.0.3) and suppress the version check.

Edit node_modules/create-react-app/createReactApp.js, change line 204 from:

if (latest && semver.lt(packageJson.version, latest)) {

to:

if (false) {

If I needed to automate this (such as in CI), I would just run sed after npm install ... and be done.