无法创建反应项目

发布于 2025-01-10 08:10:17 字数 1180 浏览 0 评论 0原文

我正在尝试使用 npm 创建一个 React 项目,但我失败了,因为不再支持 npm-create-react 的全局版本,但即使我按照告诉我的去做,它也不起作用。 当我尝试使用该命令时,

npm init react-app my-app

我从控制台收到此错误

Need to install the following packages:
  create-react-app
Ok to proceed? (y) 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 ERR! code 1
npm ERR! path /Users/nick/Documents/NFT
npm ERR! command failed
npm ERR! command sh -c create-react-app "my-app"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nick/.npm/_logs/2022-02-26T08_47_03_397Z-debug.log

在收到此错误后,我键入命令

npm uninstall -g create-react-app

并在终端中打印以下消息:


up to date, audited 1 package in 110ms

found 0 vulnerabilities

在此之后没有任何更改,我仍然收到相同的错误。 我怎样才能删除这个? 先感谢您。

I'm trying to create a React project using npm but I'm failing because the global version of npm-create-react is no longer supported but even I follow what is told me to do it doesn't work anyway.
When I try to use the command

npm init react-app my-app

I get this error from the console

Need to install the following packages:
  create-react-app
Ok to proceed? (y) 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 ERR! code 1
npm ERR! path /Users/nick/Documents/NFT
npm ERR! command failed
npm ERR! command sh -c create-react-app "my-app"

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nick/.npm/_logs/2022-02-26T08_47_03_397Z-debug.log

After I receive this error I type the command

npm uninstall -g create-react-app

And in the terminal it gets printed the following message:


up to date, audited 1 package in 110ms

found 0 vulnerabilities

After this nothing changes, I still get the same error.
How can I remove this?
Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

水中月 2025-01-17 08:10:17

尝试从 npx 运行 create React 应用程序,如下所示

npx create-react-app app-name

try running the create react app from npx like this

npx create-react-app app-name

独闯女儿国 2025-01-17 08:10:17

我通过使用这个命令使它工作

npm install -g [email protected]

然后我可以再次使用

npx create-react-app app-name

I made it work by using this command

npm install -g [email protected]

Then I could use again

npx create-react-app app-name
对你的占有欲 2025-01-17 08:10:17

您的计算机上需要有 Node >= 14.0.0 和 npm >= 5.6。要创建项目,请运行:

npx create-react-app my-app
cd my-app
npm start

Link for doc

You’ll need to have Node >= 14.0.0 and npm >= 5.6 on your machine. To create a project, run:

npx create-react-app my-app
cd my-app
npm start

Link for doc

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文