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

Ous*_*khi 21 npm reactjs create-react-app

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

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

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

Need to install the following packages:
  create-react-app
Ok to proceed? (y)
Run Code Online (Sandbox Code Playgroud)

小智 44

需要清除npx上的缓存:

npx clear-npx-cache
Run Code Online (Sandbox Code Playgroud)

然后重新运行

npx create-react-app <app-name>
Run Code Online (Sandbox Code Playgroud)

然后接受(y)


小智 16

刚刚遇到了同样的问题。这对我有用:

  • npm -g 卸载 create-react-app
  • npm 缓存清理 --force
  • npm install -g create-react-app
  • npx 创建反应应用程序我的应用程序


Ous*_*khi 1

  1. 选项1
    切换到yarn而不是npm
    npm i -g yarn
    yarn create react-app
    
    Run Code Online (Sandbox Code Playgroud)
  2. 选项2
    完全卸载节点并重新安装
  3. 选项 3
    使用nvm(节点版本管理器)