您正在运行的是 `create-react-app` 5.0.0 版本,但该版本已经落后于最新发布的版本(5.0.1)。

33

我在创建React应用程序时遇到了错误。我该如何修复它?

Microsoft Windows [Version 10.0.19044.1586]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Olususi Victor>cd documents

C:\Users\Olususi Victor\Documents>cd react folder

C:\Users\Olususi Victor\Documents\React folder>npx create-react-app blog

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/


C:\Users\Olususi Victor\Documents\React folder>

错误的图片


你尝试过错误提示中提到的命令吗?我的意思是,它明确告诉你该做什么:卸载create react app包并重新安装它 - poPaTheGuru
1
谢谢,我已经解决了,我只是卸载并重新安装了该软件包。 - Victor Mayowa
25个回答

91

请按顺序运行以下3个命令:

npm uninstall -g create-react-app
npx clear-npx-cache
npm i create-react-app
npx create-react-app@latest my-app

2
你忘记安装 npm i create-react-app - Ale DC
1
在全局安装的情况下,应该是 npm install -g create-react-app 吧? - Manish
9
我只需要运行 npx clear-npx-cache,然后它就不再抱怨了。我根本没有安装 create-react-app(全局也没有,本地也没有)。npx 只是有些笨拙。 - Radu C
你能否对这个解决方案进行解释,以改进这个答案? - Manuel Abascal

10

MacOS 12.3.1 - Node v16.3.0 - NPM 7.15.1

我尝试了很多可能的解决方案,但唯一有效的方法是全局和本地卸载CRA

因此,您需要运行以下命令:

npm uninstall -g create-react-app

npm uninstall create-react-app

npx clear-npx-cache

这个对我有用。在执行此命令后,请尝试以下操作 - npm i create-react-app,npx create-react-app@latest my-app - Shamseer

6

我遇到了相同的问题,卸载create-react-app并安装最新版本解决了这个问题:

npm uninstall -g create-react-app
npx clear-npx-cache
npm cache clean --force
npm install -g create-react-app@latest

接下来,你可以使用以下命令创建React应用:

npx create-react-app your-app-name

6
npx clear-npx-cache
npx create-react-app@latest app-name

对我有用


2

你是否全局安装了React?如果是的话,请使用以下命令卸载:

npm uninstall -g create-react-app

然后运行你的
npx create-react-app blog

如果你仍然遇到同样的问题,那么尝试创建一个博客文件夹,在该文件夹中运行以下命令。
npx create-react-app .

也许这能解决你的问题。

2
这对我有用。
npm uninstall -g create-react-app
npm i create-react-app
npx create-react-app my-app

但我仍然不确定发生了什么事情


2
今天我遇到了这个问题(运行 node v16.13.1)。具体的错误信息如下:
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/

解决方案:以下方法可行:
 1. npm uninstall -g create-react-app
 2. npm install -g create-react-app
 3. npm cache clean -f
 4. npx create-react-app my-app

2
尝试以下操作:npm uninstall -g create-react-app,然后打开C:\Users\Your_user_name\AppData\Roaming\npm-cache,删除文件夹中的所有东西。接着打开C:\Users\Your_user_name\AppData\Roaming\npm,删除与create-react-app有关的所有东西。

最后:npx create-react-app my-project。对我来说有效,祝好运!


2
我的解决方案是:
  1. npm uninstall -g create-react-app
  2. yarn uninstall -g create-react-app
  3. npm i -g create-react-app
这个方案适用于我,可以解决问题。

1

我也遇到了这个问题,通过使用yarn安装包,一切都正常工作了!即使使用npm卸载然后重新安装,也不起作用。以下是我的解决方案。

yarn add create-react-app
create-react-app {app_name}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接