【问题标题】:npm start not working | Not Loading React Applicationnpm 开始不工作 |不加载反应应用程序
【发布时间】:2021-09-21 13:37:46
【问题描述】:

npm start 命令在以下点之后没有进行 -

由于这个原因,应用程序没有被加载。

下面是 package.json -

{
  "name": "reacttest",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.12.1",
    "@material-ui/data-grid": "^4.0.0-alpha.33",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-facebook-login": "^4.1.1",
    "react-google-login": "^5.2.2",
    "react-redux": "^7.2.4",
    "react-scripts": "4.0.3",
    "redux": "^4.1.0",
    "web-vitals": "^1.1.2"
  },
  "scripts": {
    "start": "set HTTPS=true&&react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

【问题讨论】:

  • 尝试在命令提示符而不是 powershell 中运行它。我认为在powershell中按顺序运行两个命令的语法是不同的(虽然不确定它是什么)
  • @apokryfos - 也卡在控制台上的同一点

标签: javascript node.js reactjs npm


【解决方案1】:

Windows (cmd.exe)

set HTTPS=true&&npm start

Windows (Powershell)

($env:HTTPS = "true") -and (npm start)

Linux、macOS (Bash)

HTTPS=true npm start

【讨论】:

    【解决方案2】:

    在 .env 中添加变量

     REACT_APP_HTTPS = true
    

    在脚本中

    "scripts": {
        "start": "react-scripts start",
        ....
    }
    

    然后运行 ​​npm start 看看。

    【讨论】:

      猜你喜欢
      • 2021-03-11
      • 2021-10-12
      • 1970-01-01
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      • 2021-06-18
      • 2020-03-22
      • 1970-01-01
      相关资源
      最近更新 更多