为什么 npm uninstall -g create-react-app 失败?

Why npm uninstall -g create-react-app fails?

我正在 Ubuntu 20.04 机器上工作。

如果我 运行 npx create-react-app myapp 系统响应错误:

Need to install the following packages:
  create-react-app
Ok to proceed? (y) 

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/

然后,当我 运行 npm uninstall -g create-react-app 卸载时什么都不做:

xxx@xxx:/prj$ npm uninstall -g create-react-app

up to date, audited 1 package in 307ms

found 0 vulnerabilities

因此,我无法使用 npx 创建新的 React 应用程序。

有什么建议吗?

我遇到了这个问题,这对我有用,在 npm uninstall -g create-react-app 之后:


  1. npm cache clean --force
  2. npm cache verify
  3. npx clear-npx-cache 清除您的 npx 缓存。
  4. npx create-react-app your-appnpx create-react-app@latest my-app --use-npm