create-react-app: "npx create-react-app my-app" stopped working in 4.0.3
Describe the bug
/tmp
▶ npx create-react-app my-app
You are running `create-react-app` 4.0.1, which is behind the latest release (4.0.3).
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 ERR! code 1
npm ERR! path /private/tmp
npm ERR! command failed
npm ERR! command sh -c create-react-app my-app
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/peterbe/.npm/_logs/2021-02-23T16_06_05_071Z-debug.log
/tmp
▶ npx --version
7.5.6
If create-react-app
is not meant to work with npx
, then https://create-react-app.dev/docs/getting-started/ is wrong.
Did you try recovering your dependencies?
not applicable
Which terms did you search for in User Guide?
npx
- getting started
Environment
OSX Big Sur npm 7.5.6 node v15.2.1
Steps to reproduce
cd /tmp/
npx create-react-app my-app
Expected behavior
That it should create a directory called my-app
.
Actual behavior
See error above.
Reproducible demo
Not applicable.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 13
- Comments: 40 (2 by maintainers)
I just encountered this problem as well.
As a possible workaround, this worked for me:
This same kind of issue has been reported several times now:
These were all ultimately resolved with either:
Or, in one case (https://github.com/facebook/create-react-app/issues/10495#issuecomment-772893155), the exact opposite of what the error message tells you to do:
I suspect this is because the warning against “global” installs is really just checking for “is the version being run the latest version” which would be OK immediately after installing it globally, but then wouldn’t be OK two weeks & two new versions later.
There are also a lot of solutions that suggest completely uninstalling and reinstalling node &
npm
, which I think is mostly a really dramatic way to ensure you have clearednpm
’s (and presumablynpx
’s) cache of installed packages.I think there are two scenarios that can happen, and I think the error message is shown for both but the contents of the error message only apply to one of the scenarios.
create-react-app
run being out-of-date because it was installed globallycreate-react-app
run being out-of-date because it was cached bynpx
ornpm init
somewherenpx create-react-app@latest my-app
I also don’t think it helps that the error message is so definitive about the global install being the only reason you’re seeing the error (it’s not checking for a global install after all, only checking if there’s a newer version)
Thanks! This worked for me.
Latest version of npm fixed it for me.
npm install -g npm@latest
then:
<strike> asks: `Need to install the following packages: create-react-app Ok to proceed? (y)` </strike>npx create-react-app myapp
Running from terminal in VS code did not ask this, and seems to worked as usual.
This still buggy at create-react-app@4.0.3 by npx@7.18.1 which seems to come with node@16.4.1
Get around is to install create-react-app in separate project that can later be deleted.
In you parent directory:
just update npx to latest version => npm update npx
I did some digging, and this may be an
npm
bug, as we did research this at the time and as I understood, bothnpx
andyarn create
use the latest version - using the cached version only if that is the latest version.It looks like this is fixed in the latest releases of
npm
. If you can try that, and report back, that would be greatly appreciated!This was the trail I took:
npx clear-npx-cache fixed the issue for me: I no longer have to specify
@latest
to get the command to work. Should work as long as your npm version is >= 7.5.2, I believe.Thanks! It worked.
Hi,
I have tried all of the solutions but this worked for me - leaving the
npm/npx
and only usingcreate-react-app my-app
cmd ignores the errorYou are running 'create-react-app' 4.0.2, which is behind the latest release (4.0.3).
and builds the project file.Hope this would be helpful!