ipalibowhyte
ipalibowhyte

Reputation: 1563

Heroku not installing dependencies when deploying app

iv had my app running on heroku for a month now, today i added a login feature. I pushed the update which runs fine on my local machine, but when i launch on heroku, i get the error saying

An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details

This is the error im getting on the heroku console:

           ^
2014-08-23T03:33:15.894737+00:00 app[web.1]:     at Function.Module._load (module.js:280:25)
2014-08-23T03:33:15.694754+00:00 app[web.1]: > [email protected] start /app
2014-08-23T03:33:15.694756+00:00 app[web.1]: > node ./bin/www
2014-08-23T03:33:15.892108+00:00 app[web.1]: 
2014-08-23T03:33:15.892717+00:00 app[web.1]:     throw err;
2014-08-23T03:33:15.894741+00:00 app[web.1]:     at require (module.js:380:17)
2014-08-23T03:33:15.894747+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:474:10)
2014-08-23T03:33:15.894731+00:00 app[web.1]: Error: Cannot find module 'mongoose/'
2014-08-23T03:33:15.894734+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:338:15)
2014-08-23T03:33:15.894739+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-08-23T03:33:15.894753+00:00 app[web.1]:     at Module.require (module.js:364:17)
2014-08-23T03:33:15.894743+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:7:16)
2014-08-23T03:33:15.894749+00:00 app[web.1]:     at Module.load (module.js:356:32)
2014-08-23T03:33:15.901426+00:00 app[web.1]: 
2014-08-23T03:33:15.894745+00:00 app[web.1]:     at Module._compile (module.js:456:26)
2014-08-23T03:33:15.894751+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2014-08-23T03:33:14.758661+00:00 heroku[web.1]: Starting process with command `npm start`
2014-08-23T03:33:16.526792+00:00 heroku[web.1]: Process exited with status 1

This doesn't make any sense as i already have mongoose and has been sitting on app.js since i first deployed it with no problems !! urgh.

This only started when i tried the push the new update maybe because i updated my mac to yosemite ?

I have tried all i have seen online but nothing seems to work eg(heroku restart) any ideas ?

Extra Info: when deploying the app, this is what i get in terminal:

-----> Defaulting to latest stable node: 0.10.31
-----> Downloading and installing node
-----> Restoring node_modules directory from cache
-----> Pruning cached dependencies not specified in package.json
-----> Exporting config vars to environment
-----> Installing dependencies
-----> Caching node_modules directory for future builds
-----> Cleaning up node-gyp and npm artifacts
-----> No Procfile found; Adding npm start to new Procfile
-----> Building runtime environment
-----> Discovering process types
       Procfile declares types -> web

-----> Compressing... done, 8.6MB
-----> Launching... done, v27
       http://nefs.herokuapp.com/ deployed to Heroku

Kind regards

Upvotes: 1

Views: 6747

Answers (5)

Edward
Edward

Reputation: 55

I had this issue, it was because I didn't set my build pack to python

Upvotes: 0

Vignesh Nandakumar
Vignesh Nandakumar

Reputation: 119

I had this Error: Cannot find module 'ytdl-core'in heroku logs, checking the node_modules folder from heroku bash, the package was not installed. The problem was, I used 'latest' in dependencies for ytdl-core in package.json

"dependencies": {
    "express": "^4.17.1",
    "ffmpeg-static": "^4.4.0",
    "ytdl-core": "latest"
  }

Due to this ytdl-core was not getting installed. I resolved this by using npm install instead of npm ci (default in heroku) from heroku CLI

heroku config:set USE_NPM_INSTALL=true

Reference : https://devcenter.heroku.com/articles/nodejs-support

Upvotes: 0

Anurag Singh Bisht
Anurag Singh Bisht

Reputation: 2753

I was facing the same problem. Dependencies got installed the first time. After that my changes in package.json were not reflecting in the Heroku app.

This was mainly due to two reasons

  1. Heroku was caching the node_modules
  2. Heroku was running in the production mode and was ignoring the devDependencies.

Please refer to the below link where I have shared how to fix these two issues.

https://stackoverflow.com/a/45073405/3436826

Upvotes: 5

Dread Boy
Dread Boy

Reputation: 722

Another problem I had was in package.json with script property. Heroku starts Node.js applications with npm start which looks for "script" property in package.json and run that command. I changed it to

"scripts": {
  "start": "node app.js"
 },

Upvotes: 1

Daniel Pedroso
Daniel Pedroso

Reputation: 321

Really old thread, but I've had this problem today and thought it might be a good idea to place the answer here: In my case, it was the package.json file. It wasn't listing mongoose as a dependency, so an 'npm install mongoose --save' fixed the issue.

Upvotes: 1

Related Questions