【问题标题】:Can't create and run React Application无法创建和运行 React 应用程序
【发布时间】:2020-04-04 08:38:16
【问题描述】:

我正在尝试运行 create-react-app,但它似乎没有按预期的方式运行。我正在尝试以下命令:

  1. create-react-app my-app
  2. cd my-app
  3. npm start

在尝试运行时出现以下错误 如果你能帮忙,那将是enter image description here 很棒

【问题讨论】:

  • 您是否尝试过更新到最新版本的 create-react-app?你用的是什么版本?
  • 尝试更新到最新版本的 create-react 应用
  • stackoverflow.com/questions/31976722/… 看看这个对你有帮助吗?
  • 嗨,@JMadelaine 我正在使用 3.0.1

标签: reactjs npm


【解决方案1】:

你分享的日志说,创建不成功,你使用的create-react-app版本太旧了。

最好使用npx,这将确保您使用最新版本而无需任何全局安装。试试下面的命令

$ npx create-react-app festudents

【讨论】:

    【解决方案2】:

    请全局删除create-react-app试试这个npm remove -g create-react-app

    然后运行这些命令

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

    来源:https://reactjs.org/docs/create-a-new-react-app.html

    【讨论】:

    • 仍然面临同样的问题。这次我确实使用了npx
    • 我应该以管理员身份运行 cmd 我按照更新后的答案&我害怕回答结果和以前一样。
    • 是的,请以管理员身份运行
    • 同样的问题 :(
    • 试试这个 npm init react-app my-app
    【解决方案3】:

    尝试删除 creat-react-app 样板文件, 然后使用以下命令新建一个

    npx create-react-app my-app 2
    

    【讨论】:

      猜你喜欢
      • 2018-01-11
      • 2019-10-03
      • 1970-01-01
      • 1970-01-01
      • 2023-02-08
      • 2021-06-05
      • 1970-01-01
      • 2018-02-03
      • 2022-08-24
      相关资源
      最近更新 更多