Heroku上的NodeJS和Webpack

时间:2018-03-26 12:02:50

标签: node.js heroku webpack

我只是尝试将一个非常直接的nodejs服务器和webpack应用程序部署到heroku但是我从Heroku收到以下错误:

2018-03-26T12:02:19.952603+00:00 app[web.1]: webpack: Compiled successfully.
2018-03-26T11:52:19.406889+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2018-03-26T11:52:19.406889+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-03-26T11:52:19.486385+00:00 heroku[web.1]: Process exited with status 137
2018-03-26T11:52:19.497230+00:00 heroku[web.1]: State changed from starting to crashed

似乎端口有问题,但我不确定我还能做些什么。这是我的节点的样子:

/* jshint esversion: 6 */

var express = require('express');
var path = require('path');
var serveStatic = require('serve-static');

app = express();

app.use(serveStatic(__dirname + "/dist"));

var port = process.env.PORT || 5000;

app.listen(port);

和我的package.json:

{
  "name": "xxx",
  "version": "1.0.0",
  "description": "xxxx",
  "main": "index.html",
  "scripts": {
    "start": "npm run serve",
    "serve": "webpack-dev-server --colors --watch --inline --progress --content-base /src --config config/webpack.dev.js",
    "test:js": "eslint src/js/**",
    "test:scss": "stylelint src/scss/**/*.scss",
    "test": "npm run test:js && npm run test:scss",
    "build": "npm run build:dev",
    "build:dev": "ENV=dev webpack --config config/webpack.dev.js",
    "build:prod": "npm run clean && ENV=prod webpack --config config/webpack.prod.js",
    "clean": "rimraf -- dist",
    "clean:all": "rimraf -- node_modules dist"
  },
  "license": "UNLICENSED",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/xxx/xxxx.git"
  },
  "keywords": [
    "design",
    "site",
    "front-end"
  ],
  "author": "xxxx",
  "dependencies": {
   ...
  },
  "devDependencies": {
   ...
  }
}

0 个答案:

没有答案