在Heroku上部署的MERN应用的路径问题

时间:2020-08-10 04:36:52

标签: heroku mern

得到错误:ENOENT:没有这样的文件或目录,stat'/app/client/build/index.html'

package.json

  "name": "google-contacts-backend",
  "version": "1.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www",
    "dev": "nodemon ./bin/www",
    "test": "nyc _mocha --timeout 10000 --exit --report lcovonly -- -R spec",
    "lint": "eslint --fix --config .eslintrc.json \"**/*.js\"",
    "heroku-postbuild": "cd client && npm install --only=dev && npm install && npm run build"
  },
  "dependencies": {
    "axios": "^0.19.2",
    "bcrypt": "^3.0.6",
    "codacy-coverage": "^3.4.0",
    "cookie-parser": "~1.4.3",
    "cors": "^2.8.5",
    "debug": "~2.6.9",
    "dotenv": "^8.2.0",
    "express": "~4.16.0",
    "express-jwt": "^5.3.1",
    "express-validator": "^6.2.0",
    "googleapis": "^58.0.0",
    "jsonwebtoken": "^8.5.1",
    "mocha-lcov-reporter": "^1.3.0",
    "moment": "^2.24.0",
    "morgan": "~1.9.0",
    "nodemailer": "^6.3.1"
  },
  "devDependencies": {
    "chai": "^4.2.0",
    "chai-http": "^4.3.0",
    "eslint": "^6.5.1",
    "mocha": "^6.2.2",
    "nodemon": "^1.19.4",
    "nyc": "^14.1.1"
  }
}```

server.js
```app.get("*", (req, res) => {
    res.sendFile(path.join(__dirname, "client", "build", "index.html"));
});

当我尝试直接在heroku bach中检查客户端文件夹时,它是空的。

0 个答案:

没有答案