Heroku 一直从"npm"开始,即使使用 Procfile 和特定的 Web 进程



无论我是否包含Procfile,我都会让heroku在Web进程中启动"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"
}
}

索引.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: 网站:节点索引.js

所以我删除了 procile et push all on heroku,得到同样的东西,无论如何我期待根据这个阻止 Heroku 运行 npm start + 运行什么?

我有点迷茫,谢谢你的洞察力!!

你想知道什么时候使用procfile还是只使用npm脚本?

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

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

如果您有自定义脚本,请使用 procfile

希罗库开发

最新更新