【问题标题】:Node.js express + React.js pushed to Heroku not workingNode.js express + React.js 推送到 Heroku 不工作
【发布时间】:2019-04-10 07:30:34
【问题描述】:

我无法在 Heroku 上推送我的 repo。

我收到一个错误Cannot GET /

这是我的结构:

server.js
package.json (server)
  /client
    build
    package.json (client)

我的 package.json 文件:

{
  "name": "debord_slow_sender",
  "version": "1.0.0",
  "proxy": "http://localhost:5000",
  "description": "",
  "scripts": {
    "start": "node server.js",
    "client": "cd client && npm start",
    "build": "react-scripts build",
    "server": "nodemon server.js",
    "dev": "concurrently --kill-others-on-fail \"npm server\" \"npm client\"",
    "heroku-postbuild": "cd client && npm install && npm run build"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "express": "^4.16.2",
    "images-scraper": "^2.0.11",
    "ml5": "^0.1.1",
    "node-tesseract": "^0.2.7",
    "pixabay-api": "^1.0.4",
    "request": "^2.88.0",
    "socket.io": "^2.1.1"
  },
  "devDependencies": {
    "concurrently": "^3.5.0"
  }
}

任何帮助将不胜感激。

【问题讨论】:

    标签: node.js reactjs heroku npm-scripts


    【解决方案1】:

    尝试将您的 heroku-postbuild 更改为:

    "heroku-postbuild": "NPM_CONFIG_PRODUCTION=false && npm install --prefix client && npm run build --prefix client"
    

    【讨论】:

    • 我刚试了,还是不行:Cannot GET /。如果您需要更多信息,请告诉我。
    猜你喜欢
    • 2012-03-10
    • 2019-08-19
    • 1970-01-01
    • 2014-09-01
    • 1970-01-01
    • 2018-06-19
    • 2018-02-28
    • 1970-01-01
    • 2022-06-12
    相关资源
    最近更新 更多