【问题标题】:I'm having a hard time running a react command我很难运行反应命令
【发布时间】:2021-06-08 23:29:35
【问题描述】:

我刚刚更新了我的 npm 并删除了一些无用的包,但由于某种原因,我在尝试运行此命令时仍然遇到了一些奇怪的问题

kalebamarante$ npm init create-react-app kalebcryptoexchange-app
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/create-create-react-app - Not found
npm ERR! 404 
npm ERR! 404  'create-create-react-app@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kalebamarante/.npm/_logs/2021-03-09T00_18_58_939Z-debug.log
KALEBS-MacBook-Pro:~ kalebamarante$ npx create-react-app kalebcryptoexchange-app

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

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/kalebamarante
npm ERR! command failed
npm ERR! command sh -c create-react-app kalebcryptoexchange-app

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kalebamarante/.npm/_logs/2021-03-09T00_20_01_995Z-debug.log
KALEBS-MacBook-Pro:~ kalebamarante$ sh -c create-react-app kalebcryptoexchange-app
kalebcryptoexchange-app: create-react-app: command not found

【问题讨论】:

  • 你试过npx ...而不是npm init ...吗?

标签: reactjs npm npm-request


【解决方案1】:

你应该使用 npx 而不是 npm。

npx create-react-app your-app

这是为什么呢?

当您使用 npm 命令时,它会为您获取节点包。即你可能已经使用 npm 全局安装了名为“create-react-app”的包。现在要执行该包,您必须使用 npx 命令。

您的错误日志显示这一行,

npm ERR! 404  'create-create-react-app@latest' is not in the npm registry.

因为您尝试获取一个包,而不是使用 create-react-app 创建它。

简而言之,npm 下载包,npx 执行一个包。

【讨论】:

  • 漂亮而详细的答案,我投票赞成你的答案
【解决方案2】:

您应该尝试使用 npx 而不是 npm init。 npx create-react-app kalebcryptoexchange-app.

【讨论】:

  • 我使用了 npx,我删除了所有太旧的全局函数,并相应地按照说明进行操作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-01
  • 1970-01-01
相关资源
最近更新 更多