Heroku failing to start my node app because its trying to do it with nodemon
Asked Answered
H

4

9

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

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

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

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)

Any ideas?

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

Update

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.

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

With the following .buildpacks file:

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

And my Procfile looks like this:

web: bin/start-nginx ./node_modules/.bin/forever --minUptime 10000 --spinSleepTime 1000 app.js
Harridan answered 24/3, 2014 at 19:34 Comment(0)
L
12

Change your Procfile to this:

web: node app.js

Being app.js the entry point to your app.

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

Lectra answered 24/3, 2014 at 19:56 Comment(4)
Done, with no luck. I've removed scripts and nodemon dep from the package.json, and my Procfile is this: web: node app.js What's also telling is when I heroku ps i get this: === web (1X): `npm start` web.1: crashed 2014/03/24 16:18:05 (~ 1m ago) I don't have npm start or nodemon mentioned anywhere. Where is it coming from?Harridan
Hang on I've figured out what I was doing wrong all along and it had nothing to do with heroku. Thanks for the help though!Harridan
Sorry about that @ndelvalle I did edit the original question with details about the problem and the solution.Harridan
@diosney i have the same issue, how did you solve the problem?Trixie
D
3

Recently I'm working on deployed my node js appication in heroku by using nodemon, for it's working fine. we have to follow few step to reslove nodemon is not found.

1)Package.json

 npm start: nodemon server.js

2)We need to modified procfile like below.

 web: nodemon server.js

3)Use below command line to login for heroku

 $ heroku login

4)Create new application

   $heroku create <appication-name>

I think most of the developer directly deployed to heroku through github Id. Locally node_modules are work fine ,after deployed your application in heroku (inside we are n't able to access the node_modules), so for that we have access the respository.

5)Clone the repository from heroku

$ heroku git:clone -a <application-name>
$ cd cv-application

Now we are able access the application.

6)Delete you node_modules and try to install package by using below command.

$ npm install.

Deploy your changes.

$ git add .
$ git commit -am "make it better"
$ git push heroku master.

npm version sholud be 6.4.1.

Dix answered 25/6, 2019 at 5:39 Comment(1)
This will not work as nodemon needs to be installed globally, not locally. In Package.json you have the local packages onlyNasty
D
1

I know that OP got the answer but I thought I might share what worked for me, in a slightly different senario:

Procfile contains the following:

web: npm start

And for my package.json file I defined:

"scripts":{
    "start": "node ./bin/www"
}

And that fixed this issue for me.

Demoss answered 22/6, 2016 at 19:6 Comment(1)
does this automatically restart app if it crashes, it sure doesn't look like itSuperload
G
0

Include nodemon as dev dependencies not as dependencies.

using this command remove nodemon.

npm uninstall nodemon

now install nodemon

npm install -D nodemon

In production or in deployment you shouldn't be using nodemon.

Giselagiselbert answered 13/12, 2020 at 5:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.