使用 create-react-app 时未创建 public、src 和脚本文件夹

Ank*_*nha 29 reactjs create-react-app

我正在尝试使用create-react-app文档 ie 上给出的命令创建一个新项目,npx create-react-app my-app但它不包含public srcscript.

Osa*_*tab 57

尝试以下步骤:

  1. npm rm -g create-react-app
  2. npm install -g create-react-app
  3. npx create-react-app my-app

来源


小智 12

我尝试了上述所有建议,但没有一个对我有用。8097的这个建议对我有用。基本上,我只是跑npx create-react-app@latest your-project-name


小智 6

对于那些不断尝试但仍然不起作用的人,你可能会遇到和我一样的问题。

create-react-app由于不再支持全局安装,您可能已将其安装在您的计算机上,因此每当您尝试时都会运行旧版本npx create-react-app。有 2 个非常简单的步骤:删除create-react-app,然后运行 ​​npx 命令。

它看起来像这样:

  1. sudo npm rm -g create-react-appsudo在 Mac 上需要授予您权限,它会询问您的密码,输入密码并按 Enter 键)
  2. npx create-react-app my-app

那里应该能解决你的问题