create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

We no longer support global installation of Create React App

Open Arcanorum opened this issue 3 years ago • 34 comments
trafficstars

Describe the bug

I'm not comfortable with all of the critical bugs in the recently released CRA 5.0.0, so want to use the most recent reliable v4 instead, 4.0.3. Can't use npx create-react-app any more due to following error.

user:~/my-dir$ npx [email protected] my-new-app

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

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 version: 8.1.0

Steps to reproduce

Try creating a new react app using CRA.

  • npx [email protected] your-new-app
  • Get above error, app not created.
  • Try removing global install as per the given instructions with npm uninstall -g create-react-app
  • Has no effect.

Expected behavior

Should create a new CRA app. Should not care about latest release.

Actual behavior

Error.

Arcanorum avatar Feb 03 '22 21:02 Arcanorum

It's not an error it's just a warning. Facebook suggests to use latest version of CRA for creating apps. Use this instead

npx create-react-app <your-app-name>

For more info refer to this stack overflow question

theunderdogdev avatar Feb 04 '22 08:02 theunderdogdev

It's not an error it's just a warning. Facebook suggests to use latest version of CRA for creating apps. Use this instead

npx create-react-app <your-app-name>

For more info refer to this stack overflow question

You mean this one

npx create-react-app@latest <your-project-name>

I had a same problem and this has solved the problem. but should be working without designating version or latest in the future I hope.

andy5090 avatar Feb 05 '22 13:02 andy5090

Is there a way to skip this error and force running a certain version of CRA instead of installing the latest one?

codeeno avatar Feb 05 '22 15:02 codeeno

Then try this npm i -g create-react-app@<version>

Then in your folder where you want to create the application

create-react-app <app-name>

This should work

theunderdogdev avatar Feb 05 '22 16:02 theunderdogdev

I got the same error even when doing simply:

npx create-react-app my-new-app

Then I tried:

npm uninstall -g create-react-app
npx create-react-app my-new-app

Same error again.

The only way I was able to get cra working at all was via the following command:

npx create-react-app@latest my-new-app  # only command that works now!

It's not an error it's just a warning.

False. It fails to "create a react app". Therefore, it is an error.

HansBrende avatar Feb 05 '22 17:02 HansBrende

False. It fails to "create a react app". Therefore, it is an error.

Ok. I can’t verify myself coz I am running into other errors which are not very known to me. You have to wait for a developer of this package who might help you out.

theunderdogdev avatar Feb 06 '22 02:02 theunderdogdev

It won't work even if you install create-react-app as an npm package in a separate project and try to run it from there.

However there can be cases that require cra of versions lower than 5.x, i.e. when you attempt to migrate an application from custom webpack config to create-react-app and aiming for 5.x introduces significant breaking changes.

Please don't burn the bridges for those who can't jump to the latest 5.x cra :)

Bwca avatar Feb 07 '22 08:02 Bwca

Please don't burn the bridges for those who can't jump to the latest 5.x cra :)

Haha agreed! There are a lot of changes in cra 5 and it’s buggy too

theunderdogdev avatar Feb 07 '22 08:02 theunderdogdev

try it? https://zhuanlan.zhihu.com/p/296542499 I'm not good in English, sui bian kan kan~

Steps:

# WINDOWS 10

# clone cra and checkout to old version
git clone https://github.com/facebook/create-react-app.git
cd ./create-react-app
git checkout -b v4.0.3 v4.0.3

# install lerna that cra needed, and run bootstrap
npm i -g lerna
lerna bootstrap

# npx create-react-app using old files
cd ../
npx create-react-app cra-project-old --scripts-version file:.\create-react-app\packages\react-scripts --template file:.\create-react-app\packages\cra-template-typescript

# edit dependencies and re-install
cd ./cra-project-old
# replace following:
#    "react": "^17.0.2",
#    "react-dom": "^17.0.2",
#    "react-scripts": "file:../create-react-app/packages/react-scripts",
# to it:
#     "react": "^16.12.0",
#     "react-dom": "^16.12.0",
#     "react-scripts": "^4.0.3",
rimraf node_modules
rimraf package-lock.json
npm i

# it's all right!

likeke1997 avatar Feb 08 '22 09:02 likeke1997

It looks from the source code that trying to use any version but the latest version errors out.

Maintainers: could we at least get an appropriate error message if the problem is trying to use an unsupported version? Or possibly allow installing with an older version of CRA, with a warning?

DylanSp avatar Feb 09 '22 02:02 DylanSp

It's not an error it's just a warning. Facebook suggests to use latest version of CRA for creating apps. Use this instead

npx create-react-app <your-app-name>

For more info refer to this stack overflow question

You mean this one

npx create-react-app@latest <your-project-name>

I had a same problem and this has solved the problem. but should be working without designating version or latest in the future I hope.

I'll definitely be typing npx create-react-app@latest my-app until they figure this out lol.

kthewhispers avatar Feb 10 '22 08:02 kthewhispers

Seeing this as well. The instructions provided lead to an infinite loop.

godmar avatar Feb 12 '22 14:02 godmar

Possibly related to: https://github.com/facebook/create-react-app/issues/10601 and https://github.com/npm/cli/issues/2329

Also helpful: npx clear-npx-cache (This fixed the issue for me: I no longer have to specify @latest to get the command to work.)

(Though, I guess this does not fix the original issue the OP was interested in, which was CRA not allowing a version prior to latest to work.)

HansBrende avatar Feb 14 '22 00:02 HansBrende

If nothing else works for you:

  1. Create new directory
  2. npm init in it (use w/e data you want, this is throw-away directory)
  3. npm install [email protected]
  4. In node_modules/create-react-app/createReactApp.js find line if (latest && semver.lt(packageJson.version, latest)) { and change it to if (false && latest && semver.lt(packageJson.version, latest)) {
  5. Add this line to your npm scripts: create-react-app my-app --template typescript --use-npm (customize what you need)
  6. run npm run setup
  7. enjoy

rafalp avatar Feb 18 '22 23:02 rafalp

My workaround is to install globally and use global version. This will use version v4 of create-react-app instead of v5 but it will install v5 of react-scripts so it will install the latest version for the created app

WayneEllery avatar Feb 23 '22 22:02 WayneEllery

I solved this problem with this command:

npx clear-npx-cache

GioeleSalvioni avatar Mar 04 '22 09:03 GioeleSalvioni

The readme really should be updated. Right now the website displays instructions that just don't work, or at least not for everybody.

msikma avatar Mar 05 '22 09:03 msikma

I solved this problem with this command:

npx clear-npx-cache

That worked for me. The documentation should suggest that you might need to clear the npx cache.

juanmait avatar Mar 05 '22 18:03 juanmait

npx create-react-app@latest my-new-app

This Works for me, thanks

r0binxp avatar Apr 16 '22 00:04 r0binxp

If nothing else works for you:

  1. Create new directory
  2. npm init in it (use w/e data you want, this is throw-away directory)
  3. npm install [email protected]
  4. In node_modules/create-react-app/createReactApp.js find line if (latest && semver.lt(packageJson.version, latest)) { and change it to if (false && latest && semver.lt(packageJson.version, latest)) {
  5. Add this line to your npm scripts: create-react-app my-app --template typescript --use-npm (customize what you need)
  6. run npm run setup
  7. enjoy

Thanks man, this works. However, it's crazy that we need to do this to use an older version

manutorre avatar Apr 16 '22 20:04 manutorre

You should maybe try to do : npm init react-app my-app

It worked for me !

menefrego15 avatar Apr 19 '22 21:04 menefrego15

Here is what works for me:

mkdir my-app cd my-app npm i [email protected] npx [email protected] .

You could probably use @latest instead of @5.0.1.

drey-rotation avatar May 02 '22 19:05 drey-rotation

I think, that problem is deeper. There is no stable version in cra. We have only latest, but it's not stable. For example, I create app from latest and gave react 18. But storybook does not support react 18 yet. Storybook is commonly used, and it's not good just ignore that case. I don't think that is stable version, if I have to patch verisons in my final package.json.

Also I have my own template, that use my company. I'm very frustrating, when I cannot create new app. lastest cra break compatibility with common tools and have no possibility to install previous more stable version.

I suggest to support two versions - stable and latest. In that case maintainers don't have to support all possible versions of cra, but only two. If users of cra are getting errors with latest, they have stable version, that ok.

Stable version should support all common used tools like storybook by scratch.

original001 avatar May 18 '22 12:05 original001

npx clear-npx-cache

adimshev avatar Jun 20 '22 20:06 adimshev

If nothing else works for you:

  1. Create new directory
  2. npm init in it (use w/e data you want, this is throw-away directory)
  3. npm install [email protected]
  4. In node_modules/create-react-app/createReactApp.js find line if (latest && semver.lt(packageJson.version, latest)) { and change it to if (false && latest && semver.lt(packageJson.version, latest)) {
  5. Add this line to your npm scripts: create-react-app my-app --template typescript --use-npm (customize what you need)
  6. run npm run setup
  7. enjoy

ChittaMadhobi avatar Jul 27 '22 22:07 ChittaMadhobi

This is the only way it worked. I tried to clear cache, install the latest create-react-app. As many commented before, the outcome is not just a warning. It does not create an app. Hence, this is a serious bug. Create-react-app should consider a quick response.

ChittaMadhobi avatar Jul 27 '22 22:07 ChittaMadhobi

I tried every command and every suggestion here. nothing worked. It didn't provide any kind of template, not even with the template flag.

There is one thing that is working to get the template: npx create-react-app@latest <name of app>

I hope they will fix this soon.

Nessvah avatar Sep 22 '22 16:09 Nessvah

I got this issue too. I did what @adimshev said with clear cache and it worked. I was promted to install [email protected] after clearing cache and running npx cra again. Now all subsequence npx create-react-apps also work fine!

$ npx create-react-app test
You are running `create-react-app` 5.0.0, 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/
$ npx create-react-app --version
5.0.0
$ npx clear-npx-cache
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y
$ npx create-react-app test
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y

SarmanAulakh avatar Sep 25 '22 18:09 SarmanAulakh

I am really getting tired of all the problems of CRA, and still it keeps surprising me. The latest version creates apps with react 18, which might be an issue for many reasons. And now they don't even allow using older versions? Or options to select the react version to use? This is simply absurd. I work in programming education and I am really going to consider switching to another approach, no more recommending students to use this.

raquelhortab avatar Nov 03 '22 11:11 raquelhortab

I'll add to the chorus that this is completely uncool.

I received the same wrong error message following the wrong instructions that CRA publishes for "getting started". npx clear-npx-cache solved the problem. I had no, absolutely zero, packages installed globally with npm, I don't need to get gaslighted with incorrect error messages.

In this case I am putting together a toy application to debug a problem (not really React-related) with a large React application and CRA is potentially a big help if it can save time setting up. I guess for work I'd have to set the whole thing up manually with CRA and I probably would have, but if it was a side project I'd seriously think about ditching React for Svelte or somebody else who attends to having correct instructions for the most critical operation (getting started).

paulhoule avatar Jan 23 '23 16:01 paulhoule