Heroku始终以“npm”开始,即使使用Procfile和特定的Web进程也是如此

时间:2017-07-16 12:39:29

标签: node.js heroku

无论我是否包含Procfile,我都会在web进程中启动heroku“npm start”。我正在使用React / Redux构建一个简单的页面并使用webpack进行捆绑。

实际上我的项目结构是:

/projectName
 /public -->folder create during bundling with bundle.js and new html file 
 /src --> contains React and Redux components 
 .babelrc
 .gitignore
 index.html -->original html
 index.js --> express server (nothing special, just serving public/index.html on the root ("./) request)
 package.json
 Procfile (no extension, uppercase P in the name so no error there)
 webpack.config.js

所有人都在当地工作。

Package.json文件:

/ {
    "name": "redux-heroku",
    "version": "1.0.0",
    "description": "",
    "engines": {
       "node":"6.10.1"
    },

   "scripts": {
        "prod": "webpack -p",
        "start":"node index.js",
        "start:web": "webpack-dev-server"
   },

  "author": "",
  "license": "ISC",
  "dependencies": {
     "babel-core": "^6.25.0",
     "express": "^4.15.3",
     "react": "^15.6.1",
     "react-dom": "^15.6.1",
     "react-redux": "^5.0.5",
     "react-router": "^4.1.1",
     "react-router-redux": "^4.0.8",
     "redux": "^3.6.0",
      "redux-thunk": "^2.2.0"
   },
  "devDependencies": {
      "babel": "^6.23.0",
      "babel-loader": "^7.1.1",
      "babel-preset-es2015": "^6.24.1",
      "babel-preset-react": "^6.24.1",
      "css-loader": "^0.28.4",
      "html-webpack-plugin": "^2.29.0",
      "webpack": "^3.2.0",
      "webpack-dev-server": "^2.5.1"
   }
 }

index.js表达文件:

var express = require('express');
var app = express(); 
var port = process.env.port || 3000; 

app.use(express.static(__dirname +'/public')); 

app.get('/', function(req, res){
    res.render('index');
})

app.listen(port);

Procfile:     web:node index.js

所以我删除了Procile et push all on heroku,得到同样的东西,无论如何我期待的是根据这个Stopping Heroku from running npm start + what to run instead?

我有点失落,谢谢你的见解!!

1 个答案:

答案 0 :(得分:0)

你想知道何时使用procfile或只是npm脚本?

Procfiles可以包含其他流程类型。例如,您可以为后台工作进程声明一个进程,该进程处理队列中的项目。

当找不到procfile并且只有有限的scrips可用时,会执行Package.json脚本

如果您有自定义程序,请使用procfile

HEROKU DEV