Node.js app running on heroku - can't find module ./http - node.js

I'm going crazy trying to figure this out. I have a node.js app using Express and MongoDB (mongoose). It runs perfectly fine locally. I deployed it to heroku seemingly without a problem, but when I try to actually launch the app it crashes. The heroku log says this:
macbook-pro-4:FF_Courtney cmitchell$ heroku logs
2012-10-29T19:31:27+00:00 heroku[web.1]: State changed from crashed to starting
2012-10-29T19:31:30+00:00 heroku[web.1]: Starting process with command `node web.js`
2012-10-29T19:31:31+00:00 app[web.1]:
2012-10-29T19:31:31+00:00 app[web.1]: module.js:340
2012-10-29T19:31:31+00:00 app[web.1]: throw err;
2012-10-29T19:31:31+00:00 app[web.1]: Error: Cannot find module './http'
2012-10-29T19:31:31+00:00 app[web.1]: ^
2012-10-29T19:31:31+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:338:15)
2012-10-29T19:31:31+00:00 app[web.1]: at Function.Module._load (module.js:280:25)
2012-10-29T19:31:31+00:00 app[web.1]: at Module.require (module.js:362:17)
2012-10-29T19:31:31+00:00 app[web.1]: at require (module.js:378:17)
2012-10-29T19:31:31+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/express/node_modules/connect/lib/connect.js:13:18)
2012-10-29T19:31:31+00:00 app[web.1]: at Module._compile (module.js:449:26)
2012-10-29T19:31:31+00:00 app[web.1]: at Object.Module._extensions..js (module.js:467:10)
2012-10-29T19:31:31+00:00 app[web.1]: at Module.load (module.js:356:32)
2012-10-29T19:31:31+00:00 app[web.1]: at Function.Module._load (module.js:312:12)
2012-10-29T19:31:31+00:00 app[web.1]: at Module.require (module.js:362:17)
2012-10-29T19:31:32+00:00 heroku[web.1]: Process exited with status 1
I have a package.json file with my dependencies:
{
"name": "favorite-failure",
"version": "0.0.1",
"dependencies": {
"express": "2.5.6",
"ejs" : "latest",
"mongoose" : "3.3.1",
"request" : "2.11.4",
"moment" : "1.7.2",
"mongodb" : "0.9.6-7",
"connect-mongodb": ">= 1.1.3"
},
"engines": {
"node": ">= 0.8.12",
"npm": ">= 1.1.49"
}
}
I'm a bit new to this, so any help would be greatly appreciated. Thanks!

Related

Error while deploying project to heroku "return process.dlopen(module, path.toNamespacedPath(filename))"

While I was able to push successfully my master branch to Heroku and Heroku confirms my app is deployed successfully, yet, the app is not deployed despite that is shows below deploy success message: "Deploy to Heroku".
This is the whole console when log the error.
PS C:\Users\Tanuj Sharma\OneDrive\Desktop\music player\api> heroku logs --tail
» Warning: heroku update available from 7.53.0 to 7.60.2.
2022-07-10T12:46:10.179518+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:46:10.179519+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-07-10T12:46:10.179519+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-07-10T12:46:10.179519+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-07-10T12:46:10.179520+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-07-10T12:46:10.179520+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-07-10T12:46:10.179520+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-07-10T12:46:10.179521+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:46:10.179521+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-07-10T12:46:10.179522+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-07-10T12:46:10.179522+00:00 app[web.1]: }
2022-07-10T12:46:10.184303+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...
2022-07-10T12:47:08.644146+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-07-10T12:47:08.719109+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-07-10T12:47:08.735365+00:00 app[web.1]: Error waiting for process to terminate: No child processes
2022-07-10T12:47:08.854995+00:00 heroku[web.1]: Process exited with status 22
2022-07-10T12:47:08.950963+00:00 heroku[web.1]: State changed from starting to crashed
2022-07-10T12:47:08.962559+00:00 heroku[web.1]: State changed from crashed to starting
2022-07-10T12:47:11.102802+00:00 heroku[web.1]: Starting process with command `npm start`
2022-07-10T12:47:12.335764+00:00 app[web.1]:
2022-07-10T12:47:12.335778+00:00 app[web.1]: > api#1.0.0 start
2022-07-10T12:47:12.335779+00:00 app[web.1]: > nodemon index.js
2022-07-10T12:47:12.335779+00:00 app[web.1]:
2022-07-10T12:47:12.483351+00:00 app[web.1]: [nodemon] 2.0.18
2022-07-10T12:47:12.484023+00:00 app[web.1]: [nodemon] to restart at any time, enter `rs`
2022-07-10T12:47:12.484330+00:00 app[web.1]: [nodemon] watching path(s): *.*
2022-07-10T12:47:12.484372+00:00 app[web.1]: [nodemon] watching extensions: js,mjs,json
2022-07-10T12:47:12.484714+00:00 app[web.1]: [nodemon] starting `node index.js`
2022-07-10T12:47:13.021881+00:00 app[web.1]: node:internal/modules/cjs/loader:1183
2022-07-10T12:47:13.021888+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-07-10T12:47:13.021889+00:00 app[web.1]: ^
2022-07-10T12:47:13.021890+00:00 app[web.1]:
2022-07-10T12:47:13.021895+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-07-10T12:47:13.021895+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-07-10T12:47:13.021896+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:47:13.021897+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-07-10T12:47:13.021897+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-07-10T12:47:13.021898+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-07-10T12:47:13.021898+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-07-10T12:47:13.021899+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-07-10T12:47:13.021899+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-07-10T12:47:13.021899+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:47:13.021900+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-07-10T12:47:13.021900+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-07-10T12:47:13.021900+00:00 app[web.1]: }
2022-07-10T12:47:13.027964+00:00 app[web.1]: [nodemon] app crashed - waiting for file changes before starting...
2022-07-10T12:48:11.687111+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-07-10T12:48:11.799328+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-07-10T12:48:11.974808+00:00 heroku[web.1]: Process exited with status 137
2022-07-10T12:48:12.167238+00:00 heroku[web.1]: State changed from starting to crashed
2022-07-10T12:50:43.000000+00:00 app[api]: Build started by user tanujsharma56673#gmail.com
2022-07-10T12:50:57.758295+00:00 app[api]: Deploy 9d643887 by user tanujsharma56673#gmail.com
2022-07-10T12:50:57.758295+00:00 app[api]: Release v15 created by user tanujsharma56673#gmail.com
2022-07-10T12:50:58.000000+00:00 app[api]: Build succeeded
2022-07-10T12:50:58.295588+00:00 heroku[web.1]: State changed from crashed to starting
2022-07-10T12:51:02.465502+00:00 heroku[web.1]: Starting process with command `node index.js`
2022-07-10T12:51:03.881751+00:00 app[web.1]: node:internal/modules/cjs/loader:1183
2022-07-10T12:51:03.881784+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-07-10T12:51:03.881785+00:00 app[web.1]: ^
2022-07-10T12:51:03.881785+00:00 app[web.1]:
2022-07-10T12:51:03.881786+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-07-10T12:51:03.881786+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-07-10T12:51:03.881786+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:51:03.881787+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-07-10T12:51:03.881787+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-07-10T12:51:03.881787+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-07-10T12:51:03.881787+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-07-10T12:51:03.881788+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-07-10T12:51:03.881788+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-07-10T12:51:03.881789+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:51:03.881789+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-07-10T12:51:03.881789+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-07-10T12:54:36.265720+00:00 app[web.1]:
2022-07-10T12:54:36.265720+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-07-10T12:54:36.265721+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
2022-07-10T12:54:36.265721+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:54:36.265721+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-07-10T12:54:36.265721+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-07-10T12:54:36.265722+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-07-10T12:54:36.265722+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-07-10T12:54:36.265722+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14)
2022-07-10T12:54:36.265722+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
2022-07-10T12:54:36.265723+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-07-10T12:54:36.265723+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-07-10T12:54:36.265723+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-07-10T12:54:36.265724+00:00 app[web.1]: }
2022-07-10T12:54:36.415417+00:00 heroku[web.1]: Process exited with status 1
2022-07-10T12:54:37.316117+00:00 heroku[web.1]: State changed from starting to crashed
This is my index.js
This is Procfile file
package.json file
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"express-async-errors": "^3.1.1",
"joi": "^17.6.0",
"joi-password-complexity": "^5.1.0",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.4.0",
"nodemon": "^2.0.18"
}
}
Could anyone help with a precise solution?
Build log when i push to heroku
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote: engines.node (package.json): unspecified
remote: engines.npm (package.json): unspecified (use default)
remote:
remote: Resolving node version 16.x...
remote: Downloading and installing node 16.16.0...
remote: Using default npm version: 8.11.0
Any help would be great

Error: Cannot find module 'polka' on Heroku

I'm trying to deploy my sapper/svelte app to heroku but getting 'Error: Cannot find module 'polka'' this error. Interesting thing is that, it was perfectly fine and working. My package.json is correct and I am not checking my modules into git either. I tried disabling caching but it is no good. Anyone have any ideas?
2020-09-16T16:04:44.083385+00:00 app[web.1]: Error: Cannot find module 'polka'
2020-09-16T16:04:44.083386+00:00 app[web.1]: Require stack:
2020-09-16T16:04:44.083386+00:00 app[web.1]: - /app/__sapper__/build/server/server.js
2020-09-16T16:04:44.083386+00:00 app[web.1]: - /app/__sapper__/build/index.js
2020-09-16T16:04:44.083387+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
2020-09-16T16:04:44.083392+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:841:27)
2020-09-16T16:04:44.083392+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-09-16T16:04:44.083393+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-09-16T16:04:44.083393+00:00 app[web.1]: at Object.<anonymous> (/app/__sapper__/build/server/server.js:4:13)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-09-16T16:04:44.083394+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:985:32)
2020-09-16T16:04:44.083395+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:878:14)
2020-09-16T16:04:44.083395+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19) {
2020-09-16T16:04:44.083396+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-09-16T16:04:44.083396+00:00 app[web.1]: requireStack: [
2020-09-16T16:04:44.083397+00:00 app[web.1]: '/app/__sapper__/build/server/server.js',
2020-09-16T16:04:44.083397+00:00 app[web.1]: '/app/__sapper__/build/index.js'
2020-09-16T16:04:44.083397+00:00 app[web.1]: ]
2020-09-16T16:04:44.083398+00:00 app[web.1]: }
It turns out polka's version on my package.json was set to 'next'. So I changed it to it latest stable version and deleted package.lock.json file and ran 'npm install' to create a new lock file and then pushed it to heroku. Works perfectly fine.

Heroku node.js keeps crashing because of node_modules?

This is the heroku logs
2017-12-13T16:08:29.000000+00:00 app[api]: Build succeeded
2017-12-13T16:08:46.328161+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-12-13T16:08:46.498068+00:00 heroku[web.1]: Process exited with status 143
2017-12-13T16:08:53.490378+00:00 app[web.1]: module.js:538
2017-12-13T16:08:53.490391+00:00 app[web.1]: throw err;
2017-12-13T16:08:53.490391+00:00 app[web.1]: ^
2017-12-13T16:08:53.490392+00:00 app[web.1]:
2017-12-13T16:08:53.490392+00:00 app[web.1]: Error: Cannot find module './decimal128'
2017-12-13T16:08:53.490393+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2017-12-13T16:08:53.490394+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2017-12-13T16:08:53.490394+00:00 app[web.1]: at Module.require (module.js:579:17)
2017-12-13T16:08:53.490395+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-12-13T16:08:53.490395+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2017-12-13T16:08:53.490396+00:00 app[web.1]: at Module._compile (module.js:635:30)
2017-12-13T16:08:53.490396+00:00 app[web.1]: at Object.Module._extensions..js (module.js:646:10)
2017-12-13T16:08:53.490397+00:00 app[web.1]: at Module.load (module.js:554:32)
2017-12-13T16:08:53.490397+00:00 app[web.1]: at tryModuleLoad (module.js:497:12)
2017-12-13T16:08:53.490398+00:00 app[web.1]: at Function.Module._load (module.js:489:3)
2017-12-13T16:08:53.582814+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-13T16:08:53.555998+00:00 heroku[web.1]: Process exited with status 1
2017-12-13T16:08:51.503070+00:00 heroku[web.1]: Starting process with command `node app.js`
2017-12-13T16:10:20.313936+00:00 heroku[web.1]: State changed from crashed to starting
2017-12-13T16:10:23.590155+00:00 heroku[web.1]: Starting process with command `node app.js`
2017-12-13T16:10:26.548414+00:00 heroku[web.1]: Process exited with status 1
2017-12-13T16:10:26.463026+00:00 app[web.1]: module.js:538
2017-12-13T16:10:26.463042+00:00 app[web.1]: throw err;
2017-12-13T16:10:26.463042+00:00 app[web.1]: ^
2017-12-13T16:10:26.463043+00:00 app[web.1]:
2017-12-13T16:10:26.463044+00:00 app[web.1]: Error: Cannot find module './decimal128'
2017-12-13T16:10:26.463045+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:536:15)
2017-12-13T16:10:26.463045+00:00 app[web.1]: at Function.Module._load (module.js:466:25)
2017-12-13T16:10:26.463046+00:00 app[web.1]: at Module.require (module.js:579:17)
2017-12-13T16:10:26.463046+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-12-13T16:10:26.463047+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js:6:22)
2017-12-13T16:10:26.463048+00:00 app[web.1]: at Module._compile (module.js:635:30)
2017-12-13T16:10:26.463048+00:00 app[web.1]: at Object.Module._extensions..js (module.js:646:10)
2017-12-13T16:10:26.463049+00:00 app[web.1]: at Module.load (module.js:554:32)
2017-12-13T16:10:26.463050+00:00 app[web.1]: at tryModuleLoad (module.js:497:12)
2017-12-13T16:10:26.463050+00:00 app[web.1]: at Function.Module._load (module.js:489:3)
2017-12-13T16:10:26.576992+00:00 heroku[web.1]: State changed from starting to crashed
Via trial and error and using the heroku rollback it seems that the problem isn't in my app.js file but in the node_modules. However I can't seem to find a fix. I've tried reinstalling the node_modules.
It works locally but not when I deploy it on Heroku.
also suddenly I have a package-lock.json file. perhaps thats is a clue?
It's complaining about the decimal128 module, I would double check the relative path to the module from the file that is requiring it. Looks like right now it's looking for it in the same folder as the file "/decimal128".
I fixed it myself by going through everything updating everything and downgrading mongodb to "mongodb": "2.2.33"

Error with mongodb driver on Heroku: Cannot find module 'mongodb-core'

I'm trying to upgrade my Node.js Express app to a newer driver for Mongodb. My package.json has "mongodb": "^2.0.40". It runs fine on my machine, and I'm able to deploy to Heroku fine (as in, no warning/errors). However, the app crashes upon use, with this error:
2015-09-14T13:03:52.225525+00:00 heroku[web.1]: Starting process with command `node app.js`
2015-09-14T13:03:52.271972+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-09-14T13:03:54.315461+00:00 heroku[web.1]: Process exited with status 143
2015-09-14T13:03:54.701499+00:00 app[web.1]: module.js:338
2015-09-14T13:03:54.701522+00:00 app[web.1]: throw err;
2015-09-14T13:03:54.701523+00:00 app[web.1]: ^
2015-09-14T13:03:54.701525+00:00 app[web.1]: Error: Cannot find module 'mongodb-core'
2015-09-14T13:03:54.701526+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:336:15)
2015-09-14T13:03:54.701527+00:00 app[web.1]: at Function.Module._load (module.js:278:25)
2015-09-14T13:03:54.701529+00:00 app[web.1]: at require (module.js:384:17)
2015-09-14T13:03:54.701528+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-09-14T13:03:54.701531+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/mongodb/index.js:2:12)
2015-09-14T13:03:54.701532+00:00 app[web.1]: at Module._compile (module.js:460:26)
2015-09-14T13:03:54.701533+00:00 app[web.1]: at Object.Module._extensions..js (module.js:478:10)
2015-09-14T13:03:54.701534+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-09-14T13:03:54.701535+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-09-14T13:03:54.701536+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-09-14T13:03:55.561071+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-14T13:03:55.548974+00:00 heroku[web.1]: Process exited with status 1
I've tried various versions of mongodb driver, to no avail.
if you use mongodb-core, you should specify it in package.json like here:
"dependencies": {
"express": "~4.9.x"
, "pg": "~4.4.x"
, "mongodb": "2.0.14"
, "mongodb-core": "~1.0"
},
after pushing it to git, check the log:
remote: -----> Build succeeded!
remote: ├── express#4.9.8
remote: ├── mongodb#2.0.14
remote: ├── mongodb-core#1.0.5
remote: └── pg#4.4.1

morgan won't load module 'debug' on Heroku

I have this in my express settings
var morgan = require("morgan");
app.use(morgan("dev"));
This works on my development macine, but crashes when I deploy to Heroku:
heroku[web.1]: Starting process with command `node server.js`
app[web.1]: Detected 512 MB available memory, 512 MB limit per process (WEB_MEMORY)
app[web.1]: Recommending WEB_CONCURRENCY=1
app[web.1]: at Module._compile (module.js:460:26)
app[web.1]: at Object.<anonymous> (/app/node_modules/morgan/index.js:16:13)
app[web.1]: at Function.Module._load (module.js:310:12)
app[web.1]: module.js:338
app[web.1]: at Module.require (module.js:365:17)
app[web.1]: throw err;
app[web.1]: at Module.load (module.js:355:32)
app[web.1]: at Object.Module._extensions..js (module.js:478:10)
app[web.1]: ^
app[web.1]: at Module.require (module.js:365:17)
app[web.1]: Error: Cannot find module 'debug'
app[web.1]: at Function.Module._resolveFilename (module.js:336:15)
app[web.1]: at Function.Module._load (module.js:278:25)
app[web.1]: at require (module.js:384:17)
heroku[web.1]: State changed from starting to crashed
I can replicate the problem by running node from the Heroku CLI, and trying to require morgan. Anyone have an idea what I'm doing wrong?
> var morgan = require("morgan");
Error: Cannot find module 'debug'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/app/node_modules/morgan/index.js:16:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Line 16 of index.js reads var debug = require('debug')('morgan').
The debug module does lack an index.js, but has this in its package.json instead
"main": "./node.js",
"browser": "./browser.js",
"component": {
"scripts": {
"debug/index.js": "browser.js",
"debug/debug.js": "debug.js"
}
},
Turns out was something to do with an out-of-date package and updating to latest enabled me to progress

Resources