Understanding Heroku bcrypt errors in log when deploying Nodejs app - node.js

I am trying to deploy my node.js app to Heroku. It works perfectly fine locally, but when I try to deploy it I keep getting this:
2017-12-12T17:32:18.220591+00:00 app[web.1]: > ev#1.0.0 start /app
2017-12-12T17:32:18.220592+00:00 app[web.1]: > node app.js
2017-12-12T17:32:18.220592+00:00 app[web.1]:
2017-12-12T17:32:18.898850+00:00 heroku[web.1]: Process exited with status 1
2017-12-12T17:32:18.910740+00:00 heroku[web.1]: State changed from starting to crashed
2017-12-12T17:32:18.819322+00:00 app[web.1]: module.js:664
2017-12-12T17:32:18.819338+00:00 app[web.1]: return process.dlopen(module, path._makeLong(filename));
2017-12-12T17:32:18.819339+00:00 app[web.1]: ^
2017-12-12T17:32:18.819339+00:00 app[web.1]:
2017-12-12T17:32:18.819340+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/bcrypt_lib.node: invalid ELF header
2017-12-12T17:32:18.819341+00:00 app[web.1]: at Object.Module._extensions..node (module.js:664:18)
2017-12-12T17:32:18.819342+00:00 app[web.1]: at Module.load (module.js:554:32)
2017-12-12T17:32:18.819342+00:00 app[web.1]: at tryModuleLoad (module.js:497:12)
2017-12-12T17:32:18.819343+00:00 app[web.1]: at Function.Module._load (module.js:489:3)
2017-12-12T17:32:18.819343+00:00 app[web.1]: at Module.require (module.js:579:17)
2017-12-12T17:32:18.819344+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-12-12T17:32:18.819344+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2017-12-12T17:32:18.819345+00:00 app[web.1]: at Module._compile (module.js:635:30)
2017-12-12T17:32:18.819345+00:00 app[web.1]: at Object.Module._extensions..js (module.js:646:10)
2017-12-12T17:32:18.819345+00:00 app[web.1]: at Module.load (module.js:554:32)
2017-12-12T17:32:18.819346+00:00 app[web.1]: at tryModuleLoad (module.js:497:12)
2017-12-12T17:32:18.819346+00:00 app[web.1]: at Function.Module._load (module.js:489:3)
2017-12-12T17:32:18.819346+00:00 app[web.1]: at Module.require (module.js:579:17)
2017-12-12T17:32:18.819347+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-12-12T17:32:18.819347+00:00 app[web.1]: at Object.<anonymous> (/app/models/users.js:3:14)
2017-12-12T17:32:18.819347+00:00 app[web.1]: at Module._compile (module.js:635:30)
2017-12-12T17:32:18.827094+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-12-12T17:32:18.827465+00:00 app[web.1]: npm ERR! errno 1
2017-12-12T17:32:18.828807+00:00 app[web.1]: npm ERR! ev#1.0.0 start: `node app.js`
2017-12-12T17:32:18.828992+00:00 app[web.1]: npm ERR! Exit status 1
2017-12-12T17:32:18.829148+00:00 app[web.1]: npm ERR!
2017-12-12T17:32:18.829260+00:00 app[web.1]: npm ERR! Failed at the ev#1.0.0 start script.
2017-12-12T17:32:18.829357+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-12-12T17:32:18.834511+00:00 app[web.1]:
2017-12-12T17:32:18.834634+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-12-12T17:32:18.834782+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-12-12T17_32_18_830Z-debug.log
I have done npm install and npm install bcrypt again but the error persists. From my understanding of the log I think it is clear the error relates to bcrypt?
Here is my package.json file:
{
"name": "ev",
"version": "1.0.0",
"description": "search",
"main": "app.js",
"scripts": {
"start": "node app.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"bcrypt": "^1.0.3",
"body-parser": "*",
"express": "*",
"jsonwebtoken": "^8.1.0",
"mongoose": "*"
},
"author": "My Name",
"license": "ISC"

You can use a pure JS version of bcrypt library.
Something like this
https://github.com/dcodeIO/bcrypt.js
This doesnt have any native dependency and should work perfectly.
We faced a lot difficulties in deploying apps with native dependencies to heroku and other cloud platform and we had to swap some of the libraries like bcrypt with pure js versions.

Related

What is going wrong with my MERN app deployment to Heroku?

I am trying to deploy a MERN app to Heroku and this is my error log and package.json file. Can anyone see what might be causing this? I am having trouble making sense of the logs.
2020-08-18T19:02:01.418730+00:00 app[web.1]: npm ERR! Failed at the mern-test#1.0.0 start:dev script.
2020-08-18T19:02:01.418905+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-18T19:02:01.460333+00:00 app[web.1]:
2020-08-18T19:02:01.465165+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-18T19:02:01.465345+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-18T19_02_01_448Z-debug.log
2020-08-18T19:02:01.513257+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-18T19:02:01.513666+00:00 app[web.1]: npm ERR! errno 1
2020-08-18T19:02:01.518773+00:00 app[web.1]: npm ERR! mern-test#1.0.0 start: `if-env NODE_ENV=production && npm run start:prod || npm run start:dev`
2020-08-18T19:02:01.518992+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-18T19:02:01.519232+00:00 app[web.1]: npm ERR!
2020-08-18T19:02:01.519442+00:00 app[web.1]: npm ERR! Failed at the mern-test#1.0.0 start script.
2020-08-18T19:02:01.519639+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-18T19:02:01.548584+00:00 app[web.1]:
2020-08-18T19:02:01.548885+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-18T19:02:01.549093+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-18T19_02_01_529Z-debug.log
2020-08-18T19:02:01.616487+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T19:02:01.665085+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T19:02:01.668346+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-18T19:02:12.552667+00:00 heroku[web.1]: Starting process with command `npm start`
2020-08-18T19:02:15.353294+00:00 app[web.1]:
2020-08-18T19:02:15.353325+00:00 app[web.1]: > mern-test#1.0.0 start /app
2020-08-18T19:02:15.353326+00:00 app[web.1]: > if-env NODE_ENV=production && npm run start:prod || npm run start:dev
2020-08-18T19:02:15.353326+00:00 app[web.1]:
2020-08-18T19:02:15.968345+00:00 app[web.1]:
2020-08-18T19:02:15.968361+00:00 app[web.1]: > mern-test#1.0.0 start:prod /app
2020-08-18T19:02:15.968361+00:00 app[web.1]: > node server.js
2020-08-18T19:02:15.968362+00:00 app[web.1]:
2020-08-18T19:02:16.998859+00:00 app[web.1]: internal/modules/cjs/loader.js:968
2020-08-18T19:02:16.998874+00:00 app[web.1]: throw err;
2020-08-18T19:02:16.998875+00:00 app[web.1]: ^
2020-08-18T19:02:16.998875+00:00 app[web.1]:
2020-08-18T19:02:16.998876+00:00 app[web.1]: Error: Cannot find module '../../controllers/theAudioDbController'
2020-08-18T19:02:16.998876+00:00 app[web.1]: Require stack:
2020-08-18T19:02:16.998877+00:00 app[web.1]: - /app/routes/api/index.js
2020-08-18T19:02:16.998877+00:00 app[web.1]: - /app/routes/index.js
2020-08-18T19:02:16.998877+00:00 app[web.1]: - /app/server.js
2020-08-18T19:02:16.998878+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
2020-08-18T19:02:16.998878+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:841:27)
2020-08-18T19:02:16.998879+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-08-18T19:02:16.998879+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-08-18T19:02:16.998880+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api/index.js:2:30)
2020-08-18T19:02:16.998880+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-08-18T19:02:16.998880+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-08-18T19:02:16.998881+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:985:32)
2020-08-18T19:02:16.998881+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:878:14)
2020-08-18T19:02:16.998881+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1025:19)
2020-08-18T19:02:16.998882+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:72:18)
2020-08-18T19:02:16.998882+00:00 app[web.1]: at Object.<anonymous> (/app/routes/index.js:3:19)
2020-08-18T19:02:16.998883+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1137:30)
2020-08-18T19:02:16.998883+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
2020-08-18T19:02:16.998884+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:985:32)
2020-08-18T19:02:16.998923+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:878:14) {
2020-08-18T19:02:16.998924+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-08-18T19:02:16.998925+00:00 app[web.1]: requireStack: [
2020-08-18T19:02:16.998925+00:00 app[web.1]: '/app/routes/api/index.js',
2020-08-18T19:02:16.998925+00:00 app[web.1]: '/app/routes/index.js',
2020-08-18T19:02:16.998926+00:00 app[web.1]: '/app/server.js'
2020-08-18T19:02:16.998926+00:00 app[web.1]: ]
2020-08-18T19:02:16.998927+00:00 app[web.1]: }
2020-08-18T19:02:17.021432+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-18T19:02:17.021861+00:00 app[web.1]: npm ERR! errno 1
2020-08-18T19:02:17.025837+00:00 app[web.1]: npm ERR! mern-test#1.0.0 start:prod: `node server.js`
2020-08-18T19:02:17.026037+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-18T19:02:17.026255+00:00 app[web.1]: npm ERR!
2020-08-18T19:02:17.026335+00:00 app[web.1]: npm ERR! Failed at the mern-test#1.0.0 start:prod script.
2020-08-18T19:02:17.026396+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-18T19:02:17.033129+00:00 app[web.1]:
2020-08-18T19:02:17.033396+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-18T19:02:17.033590+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-18T19_02_17_028Z-debug.log
2020-08-18T19:02:17.588460+00:00 app[web.1]:
2020-08-18T19:02:17.588474+00:00 app[web.1]: > mern-test#1.0.0 start:dev /app
2020-08-18T19:02:17.588475+00:00 app[web.1]: > concurrently "nodemon --ignore 'client/*'" "npm run client"
2020-08-18T19:02:17.588476+00:00 app[web.1]:
2020-08-18T19:02:17.597996+00:00 app[web.1]: sh: 1: concurrently: not found
2020-08-18T19:02:17.617437+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-18T19:02:17.618167+00:00 app[web.1]: npm ERR! syscall spawn
2020-08-18T19:02:17.618426+00:00 app[web.1]: npm ERR! file sh
2020-08-18T19:02:17.618677+00:00 app[web.1]: npm ERR! errno ENOENT
2020-08-18T19:02:17.623336+00:00 app[web.1]: npm ERR! mern-test#1.0.0 start:dev: `concurrently "nodemon --ignore 'client/*'" "npm run client"`
2020-08-18T19:02:17.623493+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-08-18T19:02:17.623658+00:00 app[web.1]: npm ERR!
2020-08-18T19:02:17.623829+00:00 app[web.1]: npm ERR! Failed at the mern-test#1.0.0 start:dev script.
2020-08-18T19:02:17.623976+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-18T19:02:17.630596+00:00 app[web.1]:
2020-08-18T19:02:17.630799+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-18T19:02:17.630952+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-18T19_02_17_626Z-debug.log
2020-08-18T19:02:17.657848+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-08-18T19:02:17.658272+00:00 app[web.1]: npm ERR! errno 1
2020-08-18T19:02:17.663230+00:00 app[web.1]: npm ERR! mern-test#1.0.0 start: `if-env NODE_ENV=production && npm run start:prod || npm run start:dev`
2020-08-18T19:02:17.663456+00:00 app[web.1]: npm ERR! Exit status 1
2020-08-18T19:02:17.663695+00:00 app[web.1]: npm ERR!
2020-08-18T19:02:17.663882+00:00 app[web.1]: npm ERR! Failed at the mern-test#1.0.0 start script.
2020-08-18T19:02:17.664063+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-08-18T19:02:17.671333+00:00 app[web.1]:
2020-08-18T19:02:17.671650+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-08-18T19:02:17.671850+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-08-18T19_02_17_666Z-debug.log
2020-08-18T19:02:17.746107+00:00 heroku[web.1]: Process exited with status 1
2020-08-18T19:02:17.785792+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-18T19:02:20.046326+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=merntest.herokuapp.com request_id=ac795fc0-7677-4528-8f27-2f05a5f81912 fwd="99.9.203.7" dyno= connect= service= status=503 bytes= protocol=https
2020-08-18T19:02:21.701159+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=merntest.herokuapp.com request_id=288cf6cd-cff6-4943-9a89-b51bd0e8b8af fwd="99.9.203.7" dyno= connect= service= status=503 bytes= protocol=https
Here is my package.json file:
{
"name": "mern-test",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "node server.js",
"start:dev": "concurrently \"nodemon --ignore 'client/*'\" \"npm run client\"",
"client": "cd client && npm run start",
"install": "cd client && npm install",
"build": "cd client && npm run build",
"heroku-postbuild": "npm run install && npm run build "
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"bcryptjs": "^2.4.3",
"express": "^4.17.1",
"express-session": "^1.17.1",
"if-env": "^1.0.4",
"moment": "^2.27.0",
"mongoose": "^5.9.25",
"morgan": "^1.10.0",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"path": "^0.12.7",
"react-datepicker": "^3.1.3",
"react-router-dom": "^5.2.0",
"react-star-ratings": "^2.3.0",
"router": "^1.3.5"
},
"devDependencies": {
"concurrently": "^4.1.0",
"nodemon": "^2.0.4"
}
}
Please let me know if you see anything that is obviously wrong, or how I might continue to troubleshoot this. I am unsure of where to even start. Thank you.
As the Error says Error: Cannot find module '../../controllers/theAudioDbController'. Check if the file name is correct.

Error: Cannot find module - Working locally but not on Heroku

I am running a node application that I cloned from my Heroku container. locally, it runs and the app operates from localhost:3000.
However when I deploy the app using git deploy to heroku, it starts and then immediately crashes. The heroku log is pasted below.
I can't work out why I am getting this error?
I've tried updating npm, deleteing node modules.
rm -rf node_modules
npm i core-util-is
npm install -g npm#latest
The heroku log looks like:
2019-06-24T15:35:26.071317+00:00 app[web.1]: > node index.js
2019-06-24T15:35:26.071318+00:00 app[web.1]:
2019-06-24T15:35:26.251019+00:00 app[web.1]: internal/modules/cjs/loader.js:638
2019-06-24T15:35:26.251023+00:00 app[web.1]: throw err;
2019-06-24T15:35:26.251024+00:00 app[web.1]: ^
2019-06-24T15:35:26.251026+00:00 app[web.1]:
2019-06-24T15:35:26.251027+00:00 app[web.1]: Error: Cannot find module './putty'
2019-06-24T15:35:26.251031+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
2019-06-24T15:35:26.251033+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:562:25)
2019-06-24T15:35:26.251034+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:690:17)
2019-06-24T15:35:26.251036+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:25:18)
2019-06-24T15:35:26.251037+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/sshpk/lib/formats/auto.js:18:13)
2019-06-24T15:35:26.251039+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:776:30)
2019-06-24T15:35:26.251040+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
2019-06-24T15:35:26.251041+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:653:32)
2019-06-24T15:35:26.251043+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
2019-06-24T15:35:26.251044+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
2019-06-24T15:35:26.259163+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-06-24T15:35:26.259707+00:00 app[web.1]: npm ERR! errno 1
2019-06-24T15:35:26.261454+00:00 app[web.1]: npm ERR! hello#1.0.0 start: `node index.js`
2019-06-24T15:35:26.261645+00:00 app[web.1]: npm ERR! Exit status 1
2019-06-24T15:35:26.261955+00:00 app[web.1]: npm ERR!
2019-06-24T15:35:26.262153+00:00 app[web.1]: npm ERR! Failed at the hello#1.0.0 start script.
2019-06-24T15:35:26.262343+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-06-24T15:35:26.270567+00:00 app[web.1]:
2019-06-24T15:35:26.270795+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-06-24T15:35:26.270955+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-06-24T15_35_26_264Z-debug.log
I've deleted the package.json and node_modules and ran
npm init
then reinstalled the packages required, it now works.
I ran into this same issue and in my case was able to resolve by moving the alleged "missing" module from devDependencies to dependencies in package.json. For whatever reason, it didn't matter that it was saved in devDependencies locally but caused an error on Heroku until reinstalling as a regular dependency.

Deploying Vue app to Heroku, cannot find module shelljs

I am trying to deploy a vue template to our heroku instance. I have setup the procfile to call the right build script but am getting this.
Error: Cannot find module 'shelljs'
And the logs from it are:
2017-10-19T18:14:59.663986+00:00 heroku[web.1]: State changed from crashed to starting
2017-10-19T18:15:05.595940+00:00 heroku[web.1]: Starting process with command `npm run dev`
2017-10-19T18:15:13.354029+00:00 app[web.1]:
2017-10-19T18:15:13.354061+00:00 app[web.1]: > genesisui-vue#1.8.4 dev /app
2017-10-19T18:15:13.354061+00:00 app[web.1]: > node build/dev-server.js
2017-10-19T18:15:13.354062+00:00 app[web.1]:
2017-10-19T18:15:13.882843+00:00 app[web.1]: module.js:529
2017-10-19T18:15:13.882854+00:00 app[web.1]: throw err;
2017-10-19T18:15:13.882855+00:00 app[web.1]: ^
2017-10-19T18:15:13.882855+00:00 app[web.1]:
2017-10-19T18:15:13.882856+00:00 app[web.1]: Error: Cannot find module 'shelljs'
2017-10-19T18:15:13.882857+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:527:15)
2017-10-19T18:15:13.882858+00:00 app[web.1]: at Function.Module._load (module.js:476:23)
2017-10-19T18:15:13.882859+00:00 app[web.1]: at Module.require (module.js:568:17)
2017-10-19T18:15:13.882859+00:00 app[web.1]: at require (internal/module.js:11:18)
2017-10-19T18:15:13.882860+00:00 app[web.1]: at Object.<anonymous> (/app/build/check-versions.js:4:13)
2017-10-19T18:15:13.882860+00:00 app[web.1]: at Module._compile (module.js:624:30)
2017-10-19T18:15:13.882861+00:00 app[web.1]: at Object.Module._extensions..js (module.js:635:10)
2017-10-19T18:15:13.882861+00:00 app[web.1]: at Module.load (module.js:545:32)
2017-10-19T18:15:13.882862+00:00 app[web.1]: at tryModuleLoad (module.js:508:12)
2017-10-19T18:15:13.882863+00:00 app[web.1]: at Function.Module._load (module.js:500:3)
2017-10-19T18:15:13.894056+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-10-19T18:15:13.894488+00:00 app[web.1]: npm ERR! errno 1
2017-10-19T18:15:13.896140+00:00 app[web.1]: npm ERR! genesisui-vue#1.8.4 dev: `node build/dev-server.js`
2017-10-19T18:15:13.896314+00:00 app[web.1]: npm ERR! Exit status 1
2017-10-19T18:15:13.896580+00:00 app[web.1]: npm ERR!
2017-10-19T18:15:13.896777+00:00 app[web.1]: npm ERR! Failed at the genesisui-vue#1.8.4 dev script.
2017-10-19T18:15:13.896948+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-10-19T18:15:15.163061+00:00 app[web.1]:
2017-10-19T18:15:15.166845+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-10-19T18:15:15.166959+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-10-19T18_15_13_902Z-debug.log
2017-10-19T18:15:15.282631+00:00 heroku[web.1]: Process exited with status 1
2017-10-19T18:15:15.299772+00:00 heroku[web.1]: State changed from starting to crashed
Any leads would be very grateful!!!
npm install shelljs --save
git commit - m “your comment”
git push -u origin master
git push heroku master

Problems Deploying Node.js MEAN App to Heroku

My App is working locally, and is structured as follows:
MyApp
>package.json
>npm-debug.log
>readme.md
>client
>app
>node_modules
>public
>views
>bower.json
>Gruntfile.js
>package.json
>server
>config
>models
>node_modules
>routes
>app.js
>package.json
Deploying to heroku results in Application Error. The logs seem to indicate an issue with bcrypt dependency and with some Mongoose modules. Do I need to use something like MongoLabs for my app to work on Heroku? Also, I have some confusion about package.json and I'm not sure if I've implemented it properly. I have a package.json in my root directory and in my client directory and in my server directory.
package.json in root:
{
"name": "****",
"version": "1.0.0",
"description": "****",
"engines": {
"node": "4.4.7"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "cd server && node app.js"
},
"author": "*****",
"license": "ISC"
}
package.json in /server:
{
"name": "*****",
"version": "1.0.0",
"description": "******",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "******",
"license": "ISC",
"dependencies": {
"bcrypt": "^0.8.5",
"body-parser": "^1.13.2",
"connect-flash": "^0.1.1",
"cookie-parser": "^1.3.5",
"ejs": "^2.3.3",
"express": "^4.13.1",
"express-session": "^1.11.3",
"mongoose": "^4.1.0",
"mongoskin": "^1.3.20",
"morgan": "^1.6.1",
"passport": "^0.2.2",
"passport-local": "^1.0.0"
}
}
and, package.json in /client:
{
"name": "****",
"version": "1.0.0",
"description": "******",
"main": "Gruntfile.js",
"directories": {
"test": "tests"
},
"dependencies": {
"grunt": "^0.4.5"
},
"devDependencies": {
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-watch": "^0.6.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
heroku logs:
2016-07-31T23:12:37.522131+00:00 app[web.1]: ^
2016-07-31T23:12:37.522130+00:00 app[web.1]: throw e
2016-07-31T23:12:37.522133+00:00 app[web.1]: Error: /app/server/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header
2016-07-31T23:12:37.522132+00:00 app[web.1]:
2016-07-31T23:12:37.522134+00:00 app[web.1]: at Error (native)
2016-07-31T23:12:37.522136+00:00 app[web.1]: at Module.load (module.js:343:32)
2016-07-31T23:12:37.522135+00:00 app[web.1]: at Object.Module._extensions..node (module.js:434:18)
2016-07-31T23:12:37.522136+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-31T23:12:37.522137+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-31T23:12:37.522138+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-31T23:12:37.522139+00:00 app[web.1]: at Object.<anonymous> (/app/server/node_modules/bcrypt/bcrypt.js:3:35)
2016-07-31T23:12:37.522139+00:00 app[web.1]: at bindings (/app/server/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
2016-07-31T23:12:37.522140+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-31T23:12:37.522140+00:00 app[web.1]: at Object.Module._extensions..js (module.js:416:10)
2016-07-31T23:12:37.522141+00:00 app[web.1]: at Module.load (module.js:343:32)
2016-07-31T23:12:37.522142+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-31T23:12:37.522142+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-31T23:12:37.522143+00:00 app[web.1]: at Object.<anonymous> (/app/server/models/user.js:3:23)
2016-07-31T23:12:37.522143+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-31T23:12:37.522144+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-31T23:12:37.529768+00:00 app[web.1]:
2016-07-31T23:12:37.535942+00:00 app[web.1]: npm ERR! Linux 3.13.0-91-generic
2016-07-31T23:12:37.536334+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-07-31T23:12:37.536549+00:00 app[web.1]: npm ERR! node v4.4.7
2016-07-31T23:12:37.536950+00:00 app[web.1]: npm ERR! npm v2.15.8
2016-07-31T23:12:37.537269+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-07-31T23:12:37.537447+00:00 app[web.1]: npm ERR! ****#1.0.0 start: `cd server && npm install && node app.js`
2016-07-31T23:12:37.537605+00:00 app[web.1]: npm ERR! Exit status 1
2016-07-31T23:12:37.537772+00:00 app[web.1]: npm ERR!
2016-07-31T23:12:37.537933+00:00 app[web.1]: npm ERR! Failed at the ****#1.0.0 start script 'cd server && npm install && node app.js'.
2016-07-31T23:12:37.538132+00:00 app[web.1]: npm ERR! This is most likely a problem with the **** package,
2016-07-31T23:12:37.538291+00:00 app[web.1]: npm ERR! not with npm itself.
2016-07-31T23:12:37.538445+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-07-31T23:12:37.538601+00:00 app[web.1]: npm ERR! cd server && npm install && node app.js
2016-07-31T23:12:37.538768+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-07-31T23:12:37.538926+00:00 app[web.1]: npm ERR! npm bugs ****
2016-07-31T23:12:37.539078+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-07-31T23:12:37.539248+00:00 app[web.1]: npm ERR!
2016-07-31T23:12:37.539399+00:00 app[web.1]: npm ERR! npm owner ls ****
2016-07-31T23:12:37.539536+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-07-31T23:12:37.542846+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-07-31T23:12:37.542943+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-07-31T23:12:37.542671+00:00 app[web.1]:
2016-07-31T23:12:37.613094+00:00 heroku[web.1]: Process exited with status 1
2016-07-31T23:12:37.624890+00:00 heroku[web.1]: State changed from starting to crashed
2016-07-31T23:13:53.875013+00:00 heroku[api]: Deploy 3be7c63 by ****#gmail.com
2016-07-31T23:13:53.875094+00:00 heroku[api]: Release v20 created by ****#gmail.com
2016-07-31T23:13:54.082054+00:00 heroku[slug-compiler]: Slug compilation started
2016-07-31T23:13:54.082063+00:00 heroku[slug-compiler]: Slug compilation finished
2016-07-31T23:13:54.206719+00:00 heroku[web.1]: State changed from crashed to starting
2016-07-31T23:13:55.623943+00:00 heroku[web.1]: Starting process with command `npm start`
2016-07-31T23:13:57.804242+00:00 app[web.1]:
2016-07-31T23:13:57.804261+00:00 app[web.1]: > ****#1.0.0 start /app
2016-07-31T23:13:57.804262+00:00 app[web.1]: > cd server && node app.js
2016-07-31T23:13:57.804263+00:00 app[web.1]:
2016-07-31T23:13:58.379535+00:00 app[web.1]: throw e
2016-07-31T23:13:58.379536+00:00 app[web.1]: ^
2016-07-31T23:13:58.379520+00:00 app[web.1]: /app/server/node_modules/bcrypt/node_modules/bindings/bindings.js:83
2016-07-31T23:13:58.379542+00:00 app[web.1]: Error: /app/server/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header
2016-07-31T23:13:58.379544+00:00 app[web.1]: at Object.Module._extensions..node (module.js:434:18)
2016-07-31T23:13:58.379545+00:00 app[web.1]: at Module.load (module.js:343:32)
2016-07-31T23:13:58.379537+00:00 app[web.1]:
2016-07-31T23:13:58.379543+00:00 app[web.1]: at Error (native)
2016-07-31T23:13:58.379547+00:00 app[web.1]: at bindings (/app/server/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44)
2016-07-31T23:13:58.379545+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-31T23:13:58.379548+00:00 app[web.1]: at Object.<anonymous> (/app/server/node_modules/bcrypt/bcrypt.js:3:35)
2016-07-31T23:13:58.379546+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-31T23:13:58.379546+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-31T23:13:58.379549+00:00 app[web.1]: at Object.Module._extensions..js (module.js:416:10)
2016-07-31T23:13:58.379548+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-31T23:13:58.379550+00:00 app[web.1]: at Function.Module._load (module.js:300:12)
2016-07-31T23:13:58.379549+00:00 app[web.1]: at Module.load (module.js:343:32)
2016-07-31T23:13:58.379551+00:00 app[web.1]: at Module.require (module.js:353:17)
2016-07-31T23:13:58.379551+00:00 app[web.1]: at require (internal/module.js:12:17)
2016-07-31T23:13:58.387711+00:00 app[web.1]:
2016-07-31T23:13:58.393911+00:00 app[web.1]: npm ERR! Linux 3.13.0-91-generic
2016-07-31T23:13:58.394517+00:00 app[web.1]: npm ERR! node v4.4.7
2016-07-31T23:13:58.379552+00:00 app[web.1]: at Object.<anonymous> (/app/server/models/user.js:3:23)
2016-07-31T23:13:58.379552+00:00 app[web.1]: at Module._compile (module.js:409:26)
2016-07-31T23:13:58.394260+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-07-31T23:13:58.395240+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-07-31T23:13:58.395014+00:00 app[web.1]: npm ERR! npm v2.15.8
2016-07-31T23:13:58.395422+00:00 app[web.1]: npm ERR! ****#1.0.0 start: `cd server && node app.js`
2016-07-31T23:13:58.396100+00:00 app[web.1]: npm ERR! This is most likely a problem with the **** package,
2016-07-31T23:13:58.396258+00:00 app[web.1]: npm ERR! not with npm itself.
2016-07-31T23:13:58.396614+00:00 app[web.1]: npm ERR! cd server && node app.js
2016-07-31T23:13:58.395590+00:00 app[web.1]: npm ERR! Exit status 1
2016-07-31T23:13:58.395926+00:00 app[web.1]: npm ERR! Failed at the ****#1.0.0 start script 'cd server && node app.js'.
2016-07-31T23:13:58.395759+00:00 app[web.1]: npm ERR!
2016-07-31T23:13:58.396416+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-07-31T23:13:58.396937+00:00 app[web.1]: npm ERR! npm bugs ****
2016-07-31T23:13:58.396770+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-07-31T23:13:58.397098+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-07-31T23:13:58.400797+00:00 app[web.1]:
2016-07-31T23:13:58.401032+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-07-31T23:13:58.397260+00:00 app[web.1]: npm ERR!
2016-07-31T23:13:58.397418+00:00 app[web.1]: npm ERR! npm owner ls ****
2016-07-31T23:13:58.397584+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-07-31T23:13:58.401189+00:00 app[web.1]: npm ERR! /app/npm-debug.log
2016-07-31T23:13:58.456892+00:00 heroku[web.1]: Process exited with status 1
2016-07-31T23:13:58.447070+00:00 heroku[web.1]: State changed from starting to crashed
Solved. Turned out to be a problem with bcrypt dependency. By .gitignore'ing my node_modules and installing dependencies on heroku server side, everything working now.

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

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!

Resources