停止 Heroku 运行 npm start + 运行什么? [英] Stopping Heroku from running npm start + what to run instead?

查看:29
本文介绍了停止 Heroku 运行 npm start + 运行什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Disclaimer: I'm a node.js/grunt/bower newbie.

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

I have a node.js/grunt/bower application that I'm trying to deploy on Heroku. Heroku builds the application as expected, but then it tries to run "npm start" which I did not specify in the package.json file. This command fails, I'm guessing because it is not a server application, and I can not see the actual application deployed in it's place on Heroku. My application can be found here: https://github.com/uzilan/sufusku

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

So - how do I get Heroku not to run the "npm start" command, and what should it run instead? After running grunt build, the application is available on the dist folder.

package.json:

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"
    }
}

Gruntfile.js:

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']);
    });
};

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
...

推荐答案

感谢您的回答.在尝试上述教程并查看 node.js TypeError: path must be absolute 或指定 root to res.sendFile [无法解析 JSON] 我最终编写了一个 server.js 文件来解决这个问题.它看起来像这样:

Thanks for the answer. After trying the tutorial mentioned above and looking at the solutions in node.js TypeError: path must be absolute or specify root to res.sendFile [failed to parse JSON] I ended up writing a server.js file which solved the problem. And it looks like this:

var express = require('express');
var app = express();

app.get('/', function (req, res) {
    res.sendFile(__dirname + '/index.html');
});

app.get(/^(.+)$/, function (req, res) {
    res.sendFile(__dirname + req.params[0]);
});

var PORT = process.env.PORT || 3000;

app.listen(PORT);

这篇关于停止 Heroku 运行 npm start + 运行什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆