All of the existing answers are incorrect.
According to the create-react-app
docs, create-react-app
should not be installed globally:
If you've previously installed create-react-app
globally via npm install -g create-react-app
, we recommend you uninstall the package using npm uninstall -g create-react-app
or yarn global remove create-react-app
to ensure that npx
always uses the latest version.
This is even stated in the error message you recieved:
You are running create-react-app 4.0.0, which is behind the latest release (4.0.1).
We no longer support global installation of Create React App.
(Emphasis mine)
You must uninstall create-react-app
with npm uninstall -g create-react-app
.
Then each time you want to create a new React app with create-react-app
, use the command npx create-react-app my-app
.
So to fix the error you're getting, uninstall create-react-app
globally, update npm, clear the cache, and retry creating the app.
Run this in your terminal:
npm uninstall -g create-react-app && npm i -g npm@latest && sudo npm cache clean -f && npx create-react-app my-app
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…