阻止Heroku运行npm start +运行什么?

uzi*_*lan 2 heroku node.js gruntjs bower

免责声明:我是node.js/grunt/bower新手.

我有一个node.js/grunt/bower应用程序,我正在尝试在Heroku上部署.Heroku按预期构建应用程序,但随后它尝试运行"npm start",我没有在package.json文件中指定.这个命令失败了,我猜是因为它不是服务器应用程序,我看不到在Heroku上部署的实际应用程序.我的应用程序可以在这里找到:https://github.com/uzilan/sufusku

那么 - 我如何让Heroku不要运行"npm start"命令,它应该运行什么呢?运行grunt构建后,应用程序在dist文件夹中可用.

的package.json:

{
    "name": "sufusku",
    "version": "0.0.1",
    "description": "Sufusku - makes your annoying sudoku easier",
    "repository": {
        "type": "git",
        "url": "git://github.com/uzilan/sufusku.git"
    },
    "license": "(MIT OR Apache-2.0)",
    "dependencies": {
        "bower": "^1.4.1",
        "grunt": "0.4.5",
        "grunt-cli": "0.1.13",
        "grunt-contrib-clean": "^0.6.0",
        "grunt-contrib-concat": "^0.5.1",
        "grunt-contrib-connect": "^0.11.2",
        "grunt-contrib-copy": "^0.8.0",
        "grunt-contrib-cssmin": "^0.13.0",
        "grunt-contrib-htmlmin": "^0.4.0",
        "grunt-contrib-uglify": "^0.9.1",
        "grunt-contrib-watch": "^0.6.1",
        "grunt-ng-annotate": "^1.0.1",
        "load-grunt-config": "^0.17.2",
        "time-grunt": "^1.2.1"
    },
    "devDependencies": {},
    "engines": {
        "node": ">=0.8.0"
    },
    "scripts": {
        "postinstall": "./node_modules/bower/bin/bower install && grunt build"
    }
}
Run Code Online (Sandbox Code Playgroud)

Gruntfile.js:

module.exports = function (grunt) {
    var appname = require('./package.json').name;

    require('load-grunt-config')(grunt, {

        data: {
            dist: 'dist/' + appname,
            app: 'src',
            distscripts: 'dist/' + appname + '/scripts',
            diststyles: 'dist/' + appname + '/styles',
            disthtml: 'dist/' + appname,
            disttest: 'dist/' + appname + '/test',
            appstyles: 'src/css'
        }
    });

    require('time-grunt')(grunt);

    grunt.registerTask('build', ['clean:dist', 'ngAnnotate:application', 'uglify', 'htmlmin', 'cssmin', 'copy:serve', 'concat:components']);

    grunt.registerTask('serve', ['build', 'connect:livereload', 'watch']);

    grunt.registerTask('default', function () {
        grunt.task.run(['build']);
    });
};
Run Code Online (Sandbox Code Playgroud)

Heroku日志:

...
heroku[web.1]: Starting process with command `npm start`
app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
app[web.1]: npm ERR! Linux 3.13.0-57-generic
app[web.1]: npm ERR! npm  v2.11.3
app[web.1]: npm ERR! missing script: start
app[web.1]: npm ERR! Please include the following file with any support request: 
app[web.1]: npm ERR! 
app[web.1]: npm ERR! node v0.12.7
app[web.1]: 
app[web.1]: npm ERR!     /app/npm-debug.log
app[web.1]: npm ERR! If you need help, you may report this error at:
app[web.1]: 
app[web.1]: npm ERR!     <https://github.com/npm/npm/issues>
heroku[web.1]: Process exited with status 1
heroku[web.1]: State changed from starting to crashed
heroku[web.1]: State changed from crashed to starting
heroku[web.1]: Starting process with command `npm start`
app[web.1]: npm ERR! Linux 3.13.0-57-generic
app[web.1]: npm ERR! node v0.12.7
app[web.1]: 
app[web.1]: npm ERR! missing script: start
...
Run Code Online (Sandbox Code Playgroud)

hun*_*tis 16

npm startweb在Procfile中未指定其他进程时运行的默认进程.既然您说您不想要服务器(web进程),首先要做的是将默认进程扩展为零:

heroku scale web=0
Run Code Online (Sandbox Code Playgroud)

接下来,您将要告诉Heroku要运行的进程,而不是web将其进程类型添加到名为的文件中Procfile.例如,如果您的应用开始node foobar.js,您可以创建一个Procfile类似于:

bot: node foobar.js
Run Code Online (Sandbox Code Playgroud)

然后将'bot'过程扩展到至少一个:

heroku scale bot=1
Run Code Online (Sandbox Code Playgroud)

查看上面的代码,即使您说它不是基于服务器的应用程序,它看起来非常像基于服务器的应用程序.你如何在本地启动你的应用程序?无论答案应该是什么Procfile,你可以在这里了解更多:

披露:我是Heroku的Node.js平台所有者