从4.0.1版开始,create-react-app无法正常工作 [英] create-react-app is not working since version 4.0.1
问题描述
我尝试使用 npm我create-react-app
甚至是 npx create-react-app new-app
进行安装.我什至尝试了 npm init react-app new-app
.
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
.
我收到此错误消息:
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.
我该如何解决?
推荐答案
所有现有答案都不正确.
All of the existing answers are incorrect.
根据 create-react-app
docs , create-react-app
应该 不 全局安装:
According to the create-react-app
docs, create-react-app
should not be installed globally:
如果您以前通过
npm install -g create-react-app
全局安装了create-react-app
,建议您使用卸载软件包npm uninstall -g create-react-app
或yarn global remove create-react-app
,以确保npx
始终使用最新版本.
If you've previously installed
create-react-app
globally vianpm install -g create-react-app
, we recommend you uninstall the package usingnpm uninstall -g create-react-app
oryarn global remove create-react-app
to ensure thatnpx
always uses the latest version.
这甚至在您收到的错误消息中也有说明:
This is even stated in the error message you recieved:
您正在运行create-react-app 4.0.0,它落后于最新版本(4.0.1).我们不再支持在全球范围内安装Create React App.
(强调我的)
您必须使用 npm uninstall -g create-react-app
卸载 create-react-app
.
然后,每次您要使用 create-react-app
创建新的React应用时,请使用命令 npx create-react-app my-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
.
因此,要解决您遇到的错误,请全局卸载 create-react-app
,更新npm,清除缓存,然后重试创建应用.
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 && npm cache clean -f && npx create-react-app my-app
这篇关于从4.0.1版开始,create-react-app无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!