您正在运行 `create-react-app` 4.0.3 版本,该版本已落后于最新发布的版本(5.0.0)。我们不再支持全局安装 Create React App。

25
C:\Users\lg\Desktop> npm uninstall -g create-react-app

up to date, audited 1 package in 216ms

found 0 vulnerabilities
C:\Users\lg\Desktop>npx clear-npx-cache
Need to install the following packages:
  clear-npx-cache
Ok to proceed? (y) y
C:\Users\lg\Desktop>npx create-react-app@5.0.0 reduxapp
Need to install the following packages:
  create-react-app@5.0.0
Ok to proceed? (y) y
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).

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\lg\Desktop>npm i tar

up to date, audited 153 packages in 1s

6 packages are looking for funding
  run `npm fund` for details

3 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.
C:\Users\lg\Desktop>npx create-react-app@5.0.0 reduxapp

You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0).

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/

我尝试通过谷歌搜索来解决它,但出现了一个错误,文件夹无法创建。

在这里输入图片描述


如文档所建议,使用 npx create-react-app my-app - Ramesh Reddy
我尝试了一下,"您正在运行 create-react-app 4.0.3 版本,该版本已经落后于最新版本 (5.0.0)。 我们不再支持全局安装 Create React App。" 同样的警告。 - JeongHaSeung
请确保您使用的是 npx 而不是 npm - Ramesh Reddy
哪个部分?我想我正在使用npx。 - JeongHaSeung
9个回答

60

如果您最近在旧版本上运行过此命令,请尝试清除npx-cache。

npx clear-npx-cache
npx install -g create-react-app react-app

这对我有用。谢谢! - crocarneiro
2
npx 如果有 @latest 版本是否会使用它?我以为这就是该命令的目的?由于 npx 会缓存,所以我想知道它与 npm i -g 的区别在哪里? - Steve
1
我正在使用 nvm,这个方法对我很有用。我已经尝试了几次全局卸载,但都没有成功。 - killshot13
2
清除缓存,然后运行 npx create-react-app react-app 对我有用!谢谢! - 36Boxes
1
这应该是被接受的答案... - Will59
建议不要使用全局安装的 create-react-app,但清除缓存肯定可以修复安装问题。清除缓存后运行 npx create-react-app <project-name> 即可。 - Andrew Serra

18

以下命令对我有效:

npx create-react-app@latest my-app

10

所以这是我所采取的步骤来使它正常工作:

npm uninstall -g create-react-app

npx create-react-app@latest my-app-name

8
清空 npx 缓存解决了我的问题:
npx clear-npx-cache

2
此外,您可以以管理员身份进入控制台,该控制台位于用户文件夹中,并输入此命令(在我的情况下,我使用了NPM):
npm uninstall -g create-react-app 我们卸载它,然后重新安装它:
npm install -g create-react-app 这样就行了,对我来说起作用了。

1

如果您之前在旧版本上运行过此操作,就会出现这种情况

步骤1:尝试通过运行以下命令来清除缓存: npx clear-npx-cache

步骤2:创建应用的通用命令: npx install -g create-react-app react-app


1
清除缓存有所帮助。谢谢! - Tamas Kalman

0

运行命令:npx clear-npx-cache

安装 create-react-app:npm install -g create-react-app

创建 React 应用:npx create-react-app@latest my-app


虽然这段代码可能解决了问题,但是包括解释它如何以及为什么解决了问题,将有助于提高您的帖子质量。请记住,您正在回答未来读者的问题,而不仅仅是现在提问的人。请[编辑]您的答案以添加解释,并指出适用的限制和假设。 - Cristik

0

要解决这个问题,请运行以下代码:npx create-react-app@5.0.1 reduxapp 请注意安装最新版本的create-react-app,否则可能无法正常工作。


0
这是由于最新版本的create-react-app(5.0.1)发布导致的,您需要做的就是首先通过运行以下命令卸载先前版本的create-react-appnpm uninstall -g create-react-app 或者只需更新先前的版本 npm update -g create-react-app

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