create-react-app React应用无法安装

roqulrg3  于 2个月前  发布在  React
关注(0)|答案(8)|浏览(32)

我正在创建我的React应用时遇到问题。

b1payxdu

b1payxdu1#

你尝试过更新节点和包管理器吗?你使用的是哪个?还有操作系统。

os8fio9y

os8fio9y2#

我也无法创建一个新的React应用。
当运行npx create-react-app my-app时,进程在几秒钟后停止:

npm http fetch GET 200 https://registry.npmjs.org/create-react-app 212ms (cache revalidated)
Need to install the following packages:
  create-react-app
Ok to proceed? (y) 
npm http fetch GET 200 https://registry.npmjs.org/create-react-app 6ms (cache hit)
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 341ms
npm http fetch GET 200 https://registry.npmjs.org/tar 50ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/tar-pack 841ms (cache revalidated)

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/

我没有全局安装create-react-app
npm list -g给出:

├── @mdxp/create-webpack@0.2.5
├── corepack@0.10.0
├── decktape@3.4.0
├── http-server@14.0.0
├── npm@8.1.2
├── pnpm@6.25.1
└── vue-spotlight@

我正在使用Node版本16.13.1,通过nvm安装。

rn0zuynd

rn0zuynd3#

我正在创建我的React应用时遇到了问题。
请使用以下命令卸载create-react-app:npm uninstall -g create-react-app,然后再次使用npm install -g create-react-app重新安装。今天我刚刚遇到了这个问题。
或者使用npx create-react-app

piwo6bdm

piwo6bdm4#

我也遇到了同样的问题,使用 npx create-react-app@latest my-app 解决了。也许你可以试试看。

zsbz8rwp

zsbz8rwp5#

感谢@thanhpd,你的解决方案有效。

6mw9ycah

6mw9ycah6#

为什么我们必须执行npx create-react-app@latest才能使这个工作?这似乎是一个bug,无论是在npm、npx还是create-react-app中。

i7uq4tfw

i7uq4tfw7#

可能的重复问题:#12022

ztigrdn8

ztigrdn88#

我遇到了类似的问题。
Mac V12.1

  • Node 版本 14.x、16.x 和 17.x
  • npm cache clean --force
  • sudo npm uninstall -g create-react-app
  • npx clear-npx-cache

使用带版本号的 create-react-app 并不总是有效。例如:
nvm use 14 - creaet-react-app@5.0.0 正确设置
nvm use 16 - creaet-react-app@5.0.0 无法设置,提示 "A template was not provided. This is likely because you're using an outdated version of create-react-app."

相关问题