无法使用 create-react-app 创建 React 应用程序

时间:2021-04-23 16:49:58

标签: reactjs npm create-react-app

当我运行以下命令 npx create-react-app my-app 时,我在使用 CRA 创建新的 React 应用程序时遇到问题。

  • 我尝试使用此命令清除 npm 缓存 npm cache clean --force
  • 我也试过这个命令 npm -g uninstall create-react-app

我的 node 版本是 v14.15.3,npm 版本是 7.10.0
我得到的错误是:

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

2 个答案:

答案 0 :(得分:0)

当它给你这个错误时,它会征求你的许可来安装 create-react-app

...
Ok to proceed? (y)

在终端中输入 y 并按 enter

您可能会发现这也很有帮助: https://create-react-app.dev/docs/getting-started/

<块引用>

如果您之前已经通过 npm 全局安装了 create-react-app install -g create-react-app,我们建议您卸载该软件包 使用 npm uninstall -g create-react-app 或 yarn global remove create-react-app 以确保 npx 始终使用最新版本。

答案 1 :(得分:0)

您能否尝试将此路径添加到您的系统变量中? C:\Users\<user-name>\AppData\Roaming\npm

然后使用 npx create-react-app <app-name>

重试
相关问题