简体   繁体   English

Heroku始终以“ npm”开始,甚至从Procfile和特定的Web进程开始

[英]Heroku allways starting “npm” start even with Procfile and specific web process

I am getting heroku starting "npm start" on web process no matter I include Procfile or not. 无论是否包含Procfile,我都会在Web进程上让heroku启动“ npm start”。 I am building a simple page with React/Redux and using webpack to bundle. 我正在用React / Redux构建一个简单的页面,并使用webpack进行捆绑。

Actually my project structure is: 实际上我的项目结构是:

/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

All is working in local. 所有人都在当地工作。

the Package.json file : 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"
   }
 }

The index.js express file : 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);

The Procfile: web: node index.js Procfile:web:节点index.js

So I delete the Procile et push all on heroku, getting the same thing, anyway I was expecting that according to this Stopping Heroku from running npm start + what to run instead? 所以我删除了所有在heroku上的Procile et push,得到了同样的东西,无论如何,我一直期待根据此停止Heroku运行npm start +改为运行什么?

I am a bit lost, thank you for you insight!! 我有点迷路,谢谢您的见识!

do you want to know when to use procfile or just npm scripts? 您是否想知道何时使用procfile或仅使用npm脚本?

Procfiles can contain additional process types. Procfile可以包含其他进程类型。 For example, you might declare one for a background worker process that processes items off of a queue. 例如,您可以为后台工作进程声明一个,该工作进程处理队列之外的项目。

Package.json scripts are executed when procfile is not found and only limited scrips are available 当找不到procfile并且只有有限的脚本可用时,将执行Package.json脚本

If you have custom scrips you use procfile 如果您有自定义脚本,则使用procfile

HEROKU DEV 英雄发展

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM