Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
236 views
in Technique[技术] by (71.8m points)

node.js - create-react-app is not working since version 4.0.1

I tried installing using npm i create-react-app and even npx create-react-app new-app. I even tried npm init react-app new-app.

I'm getting this error message:

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.

How can I fix this?

question from:https://stackoverflow.com/questions/64963796/create-react-app-is-not-working-since-version-4-0-1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...