Heroku 无法启动我的节点应用程序,因为它试图用 nodemon 来完成 [英] Heroku failing to start my node app because its trying to do it with nodemon

查看:55
本文介绍了Heroku 无法启动我的节点应用程序,因为它试图用 nodemon 来完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的节点应用程序部署到 Heroku,它试图用 nodemon 而不是我定义的 node app.js 来调用它.我的 Procfile 看起来像这样:

I'm deploying my node app to Heroku and it's trying to invoke it with nodemon rather than the node app.js I have defined. My Procfile looks like this:

web: npm start

当我推送到 heroku 时,dyno 因此错误而崩溃:

And when I push to heroku the dyno crashes with this error:

2014-03-24T19:24:59.669412+00:00 app[web.1]: > my-app@0.0.1 start /app
2014-03-24T19:24:59.669412+00:00 app[web.1]: > nodemon app.js
2014-03-24T19:24:59.669412+00:00 app[web.1]:
2014-03-24T19:24:59.669412+00:00 app[web.1]:
2014-03-24T19:24:59.710228+00:00 app[web.1]:
2014-03-24T19:24:59.701246+00:00 app[web.1]: sh: nodemon: not found

我什至尝试 npm 安装 nodemon 作为 package.json 依赖项,并检查 node_modules/nodemon 但没有运气.(nodemon 需要使用 npm install nodemon -g 安装才能正常工作)

I even tried npm installing nodemon as a package.json dependency, and checking in node_modules/nodemon but no luck. (nodemon needs to be installed with npm install nodemon -g for that to work anyway)

有什么想法吗?

我的 package.json:

My package.json:

{
    "name": "my-app",
    "version": "0.0.1",
    "private": true,
    "main": "app.js",
    "scripts": {
        "start": "node app.js"
    },
    "dependencies": {
        "requirejs": "~2.1.10",
        "underscore": "~1.5.2",
        "express": "~3.4.8",
        "ejs": "~0.8.5",
        "less-middleware": "~0.1.15",
        "socket.io": "~0.9.16",
        "tail": "~0.3.5",
        "async": "~0.2.10",
        "mongoose": "~3.8.5",
        "mkdirp": "~0.3.5",
        "ejs-locals": "~1.0.2",
        "aws-sdk": "~2.0.0-rc8",
        "knox": "~0.8.8",
        "connect-multiparty": "~1.0.3",
        "uuid": "~1.4.1",
        "nodemon": "~1.0.14"
    },
    "devDependencies": {
        "grunt": "~0.4.2",
        "grunt-contrib-clean": "~0.5.0",
        "grunt-contrib-copy": "~0.4.1",
        "grunt-contrib-requirejs": "~0.4.1",
        "grunt-recess": "~0.5.0",
        "grunt-contrib-cssmin": "~0.7.0",
        "grunt-mocha-test": "~0.9.0",
        "grunt-forever": "~0.4.1",
        "matchdep": "~0.3.0",
        "jshint": "~2.4.3",
        "precommit-hook": "~0.3.10",
        "mocha": "~1.17.1",
        "supertest": "~0.9.0",
        "chai": "~1.9.0",
        "sinon": "~1.8.2",
        "karma-sinon": "~1.0.2",
        "karma-script-launcher": "~0.1.0",
        "karma-chrome-launcher": "~0.1.2",
        "karma-firefox-launcher": "~0.1.3",
        "karma-requirejs": "~0.2.1",
        "karma-html2js-preprocessor": "~0.1.0",
        "karma-jasmine": "~0.1.5",
        "karma-coffee-preprocessor": "~0.1.3",
        "karma-phantomjs-launcher": "~0.1.2",
        "karma": "~0.10.9",
        "karma-mocha": "~0.1.1",
        "grunt-karma": "~0.6.2",
        "karma-chai": "~0.1.0"
    },
    "config": {
        "precommit": {
            "lint": true
        }
    },
    "engines": {
        "node": "0.10.x"
    }
}

更新

很抱歉让大家一直挂着!如果我没记错的话,我最后的问题是我的 buildpack 覆盖了 web: 角色在我的 Procfile 中.

Sorry to have left everyone hanging all this time! If I remember correctly my issue in the end was my buildpack which was overriding the web: role in my Procfile.

我已经切换到不同的构建包,即:ddollar/heroku-buildpack-multi

I've since switched to different buildpacks, namely: ddollar/heroku-buildpack-multi

使用以下 .buildpacks 文件:

With the following .buildpacks file:

ryandotsmith/nginx-buildpack
heroku/heroku-buildpack-nodejs

我的 Procfile 看起来像这样:

And my Procfile looks like this:

web: bin/start-nginx ./node_modules/.bin/forever --minUptime 10000 --spinSleepTime 1000 app.js

推荐答案

将您的 Procfile 更改为:

web: node app.js

成为 app.js 应用程序的入口点.

Being app.js the entry point to your app.

这是假设您的应用中并不真正需要 nodemon,因为您已在您提供的 package.json 示例中列出了它.

This is assuming you don't really need nodemon in your app, since you have listed it at the package.json sample you provided.

这篇关于Heroku 无法启动我的节点应用程序,因为它试图用 nodemon 来完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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