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

web: npm start

当我将按钮推到heroku时,dyno崩溃,并显示以下错误:
2014-03-24T19:24:59.669412+00:00 app[web.1]: > [email protected] 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才能正常工作)

有任何想法吗?

我的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,它覆盖了Procfile中的web:角色。

从那以后,我切换到了不同的buildpack,即:
ddollar/heroku-buildpack-multi

使用以下.buildpacks文件:
ryandotsmith/nginx-buildpack
heroku/heroku-buildpack-nodejs

我的Procfile看起来像这样:
web: bin/start-nginx ./node_modules/.bin/forever --minUptime 10000 --spinSleepTime 1000 app.js

最佳答案

将您的Procfile更改为此:

web: node app.js

作为app.js,您的应用程序的入口点。

这是假设您确实不需要在应用程序中使用nodemon,因为您已在提供的package.json示例中列出了它。

关于node.js - Heroku无法启动我的 Node 应用程序,因为它试图使用nodemon来执行它,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22618930/

10-16 00:23