Skip to content
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

We no longer support global installation of Create React App #12022

Open
Arcanorum opened this issue Feb 3, 2022 · 34 comments
Open

We no longer support global installation of Create React App #12022

Arcanorum opened this issue Feb 3, 2022 · 34 comments

Comments

@Arcanorum
Copy link

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 create-react-app@4.0.3 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 create-react-app@4.0.3 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.

@theunderdogdev
Copy link

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

@andy5090
Copy link

andy5090 commented Feb 5, 2022

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.

@codeeno
Copy link

codeeno commented Feb 5, 2022

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

@theunderdogdev
Copy link

theunderdogdev commented Feb 5, 2022

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

@HansBrende
Copy link

HansBrende commented Feb 5, 2022

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.

@theunderdogdev
Copy link

theunderdogdev commented Feb 6, 2022

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.

@Bwca
Copy link

Bwca commented Feb 7, 2022

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 :)

@theunderdogdev
Copy link

theunderdogdev commented Feb 7, 2022

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

@likeke1997
Copy link

likeke1997 commented Feb 8, 2022

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!

@DylanSp
Copy link

DylanSp commented Feb 9, 2022

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?

@kthewhispers
Copy link

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.

@godmar
Copy link

godmar commented Feb 12, 2022

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

@HansBrende
Copy link

HansBrende commented Feb 14, 2022

Possibly related to: #10601 and npm/cli#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.)

@rafalp
Copy link

rafalp commented Feb 18, 2022

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 create-react-app@4.0.3
  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

@WayneEllery
Copy link

WayneEllery commented Feb 23, 2022

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

@GioeleSalvioni
Copy link

I solved this problem with this command:

npx clear-npx-cache

@msikma
Copy link

msikma commented Mar 5, 2022

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

@juanmait
Copy link

juanmait commented Mar 5, 2022

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.

@r0binxp
Copy link

r0binxp commented Apr 16, 2022

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

This Works for me, thanks

@manutorre
Copy link

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 create-react-app@4.0.3
  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

@menefrego15
Copy link

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

It worked for me !

@drey-rotation
Copy link

Here is what works for me:

mkdir my-app
cd my-app
npm i create-react-app@5.0.1
npx create-react-app@5.0.1 .

You could probably use @latest instead of @5.0.1.

@original001
Copy link

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.

@adimshev
Copy link

npx clear-npx-cache

@ChittaMadhobi
Copy link

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 create-react-app@4.0.3
  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
Copy link

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.

@Nessvah
Copy link

Nessvah commented Sep 22, 2022

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.

@SarmanAulakh
Copy link

I got this issue too. I did what @adimshev said with clear cache and it worked. I was promted to install create-react-app@5.0.1 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:
  clear-npx-cache@1.0.1
Ok to proceed? (y) y
$ npx create-react-app test
Need to install the following packages:
  create-react-app@5.0.1
Ok to proceed? (y) y

@raquelhortab
Copy link

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.

cheshire137 added a commit to cheshire137/gohuedata that referenced this issue Dec 24, 2022
npx create-react-app@latest ui --template typescript --use-npm

Because:

```
npx create-react-app ui --template typescript --use-npm

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.
```

Even though:

```
% which create-react-app
create-react-app not found
```

```
% npm uninstall -g create-react-app

up to date, audited 1 package in 121ms

found 0 vulnerabilities
```

```
% yarn global remove create-react-app
yarn global v1.22.17
[1/2] 🗑  Removing module create-react-app...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/global for documentation about this command.
```

See facebook/create-react-app#12022.
@paulhoule
Copy link

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).

@Bakhaow
Copy link

Bakhaow commented Jan 23, 2023

Having the same issue i came there but i found a way to pass through this error:

Wanting to create a react app with "npx create-react-app ." ?

use instead

cd ../
npm i create-react-app@latest
npx create-react-app
cd

Hope it can helps

& Also Enjoy Coding

@Rishijay
Copy link

Rishijay commented May 7, 2023

Just like any other library upgrade, I upgraded "create-react-app" and it worked in 2 simple steps :-

  1. Global Uninstall Create React App (just to make sure previous version doesn't conflict with latest) :- npm uninstall -g create-react-app

  2. Global Install Create React App (by default it installs latest version) :- npm install -g create-react-app

Now, create react app with npx create-react-app <your-project-name>

@Weapon-X6
Copy link

buggy

I use React here and there, everything I come back is buggy

@cabiamdos
Copy link

to fix it go to %appdata%/npm/node_modules if you are on windows, and in the createReactApp.js remove the "process.exit(1)"
image
image
image
and the if else statement so that the log part doesn't execute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests