I have successfully deployed some simple nodeJS applications using the Heroku platform.
Now I want to deploy a full application using:
1) a MongoDB database hosted at MongoLab;
2) AngularJS+Bootstrap for the front-end component;
Is this possible to deploy to Heroku?
If so, what changes do I need to apply to the git repo and the Procfile to make it work?
Right now, my github repo looks like this:
Is this the correct structure?
I'm aware of the need to listen on: process.env.PORT instead of a fixed one and I'm also aware of building the package.json automatically using npm init.
For some reason, I can't deploy and I get this error log:
2015-10-01T08:07:01.099635+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-10-01T08:07:03.847353+00:00 app[web.1]: module.js:338
2015-10-01T08:07:03.847392+00:00 app[web.1]: at Module._compile (module.js:434:26)
2015-10-01T08:07:03.847378+00:00 app[web.1]: throw err;
2015-10-01T08:07:03.847394+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-10-01T08:07:03.847380+00:00 app[web.1]: ^
2015-10-01T08:07:03.847393+00:00 app[web.1]: at Object.Module._extensions..js (module.js:452:10)
2015-10-01T08:07:03.847381+00:00 app[web.1]:
2015-10-01T08:07:03.847396+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-10-01T08:07:03.847383+00:00 app[web.1]: Error: Cannot find module 'xmlbuilder'
2015-10-01T08:07:03.847397+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-10-01T08:07:03.847385+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:336:15)
2015-10-01T08:07:03.847386+00:00 app[web.1]: at Function.Module._load (module.js:286:25)
2015-10-01T08:07:03.847387+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-10-01T08:07:03.847389+00:00 app[web.1]: at require (module.js:384:17)
2015-10-01T08:07:03.847390+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/nodemailer/node_modules/aws-sdk/lib/xml/builder.js:2:15)
2015-10-01T08:07:03.847398+00:00 app[web.1]: at require (module.js:384:17)
2015-10-01T08:07:03.847400+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/nodemailer/node_modules/aws-sdk/lib/core.js:42:14)
2015-10-01T08:07:03.847401+00:00 app[web.1]: at Module._compile (module.js:434:26)
2015-10-01T08:07:03.847402+00:00 app[web.1]: at Object.Module._extensions..js (module.js:452:10)
2015-10-01T08:07:03.847403+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-10-01T08:07:03.847405+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-10-01T08:07:04.829102+00:00 heroku[web.1]: State changed from starting to crashed
2015-10-01T08:07:04.815963+00:00 heroku[web.1]: Process exited with status 1
2015-10-01T08:07:23.430743+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testeapp8.herokuapp.com request_id=185f6386-0265-494c-8e54-0cc5eec303e5 fwd="81.11.174.99" dyno= connect= service= status=503 bytes=
2015-10-01T08:15:48.636079+00:00 heroku[web.1]: State changed from crashed to starting
2015-10-01T08:15:52.227188+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-10-01T08:15:55.940813+00:00 app[web.1]: module.js:338
2015-10-01T08:15:55.940832+00:00 app[web.1]: throw err;
2015-10-01T08:15:55.940834+00:00 app[web.1]: ^
2015-10-01T08:15:55.940835+00:00 app[web.1]:
2015-10-01T08:15:55.940837+00:00 app[web.1]: Error: Cannot find module 'xmlbuilder'
2015-10-01T08:15:55.940839+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:336:15)
2015-10-01T08:15:55.940840+00:00 app[web.1]: at Function.Module._load (module.js:286:25)
2015-10-01T08:15:55.940841+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-10-01T08:15:55.940843+00:00 app[web.1]: at require (module.js:384:17)
2015-10-01T08:15:55.940844+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/nodemailer/node_modules/aws-sdk/lib/xml/builder.js:2:15)
2015-10-01T08:15:55.940845+00:00 app[web.1]: at Module._compile (module.js:434:26)
2015-10-01T08:15:55.940847+00:00 app[web.1]: at Object.Module._extensions..js (module.js:452:10)
2015-10-01T08:15:55.940848+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-10-01T08:15:55.940849+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-10-01T08:15:55.940850+00:00 app[web.1]: at Module.require (module.js:365:17)
2015-10-01T08:15:55.940852+00:00 app[web.1]: at require (module.js:384:17)
2015-10-01T08:15:55.940853+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/nodemailer/node_modules/aws-sdk/lib/core.js:42:14)
2015-10-01T08:15:55.940854+00:00 app[web.1]: at Module._compile (module.js:434:26)
2015-10-01T08:15:55.940857+00:00 app[web.1]: at Module.load (module.js:355:32)
2015-10-01T08:15:55.940858+00:00 app[web.1]: at Function.Module._load (module.js:310:12)
2015-10-01T08:15:55.940856+00:00 app[web.1]: at Object.Module._extensions..js (module.js:452:10)
2015-10-01T08:15:56.867807+00:00 heroku[web.1]: State changed from starting to crashed
2015-10-01T08:15:56.847462+00:00 heroku[web.1]: Process exited with status 1
Related
Error in deployment. How to solve this?
2020-11-08T09:30:21.366810+00:00 app[web.1]: Error: libopencv_core.so.3.4: cannot open shared object file: No such file or directory
2020-11-08T09:30:21.366811+00:00 app[web.1]: at Object.Module._extensions..node (internal/modules/cjs/loader.js:1003:18)
2020-11-08T09:30:21.366812+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:812:32)
2020-11-08T09:30:21.366812+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-08T09:30:21.366812+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:849:19)
2020-11-08T09:30:21.366813+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-11-08T09:30:21.366813+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/opencv4nodejs/lib/cv.js:40:8)
2020-11-08T09:30:21.366813+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:956:30)
2020-11-08T09:30:21.366814+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
2020-11-08T09:30:21.366814+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:812:32)
2020-11-08T09:30:21.366814+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-08T09:30:21.366814+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:849:19)
2020-11-08T09:30:21.366815+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-11-08T09:30:21.366815+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/opencv4nodejs/lib/opencv4nodejs.js:11:79)
2020-11-08T09:30:21.366815+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:956:30)
2020-11-08T09:30:21.366816+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
2020-11-08T09:30:21.366816+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:812:32)
The app crashes everytime showing this error. How to fix this?
Follow the below steps in order to use Open CV inside Heroku
Add heroku-buildpack-apt to your Heroku Build packs. You can go to your app's settings page and add build packs.
Create a file named Aptfile and add the following libs: libsm6, libxrender1, libfontconfig1, libice6. Follow the example below:
libsm6
libxrender1
libfontconfig1
libice6
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.
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"
I'm using nodebootstrap to start a new nodejs project (http://nodebootstrap.io/) and it's running fine locally. But when I tried to deploy it to heroku, it showed me the follow errors:
2016-08-21T05:14:51.789857+00:00 heroku[web.1]: State changed from crashed to starting
2016-08-21T05:14:54.116827+00:00 heroku[web.1]: Starting process with command `node server.js`
2016-08-21T05:14:56.026808+00:00 app[web.1]: 21 Aug 05:14:56 - NOTICE [node_modules/nodebootstrap-server/app.js:57] Express server instance listening on port 31254
2016-08-21T05:14:56.104762+00:00 app[web.1]: module.js:341
2016-08-21T05:14:56.104766+00:00 app[web.1]: throw err;
2016-08-21T05:14:56.104769+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:339:15)
2016-08-21T05:14:56.104773+00:00 app[web.1]: at Function.Module._load (module.js:290:25)
2016-08-21T05:14:56.104775+00:00 app[web.1]: at require (internal/module.js:20:19)
2016-08-21T05:14:56.104775+00:00 app[web.1]: at Object.<anonymous> (/app/lib/api/index.js:2:9)
2016-08-21T05:14:56.104776+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-08-21T05:14:56.104777+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-08-21T05:14:56.104777+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-08-21T05:14:56.158230+00:00 heroku[web.1]: State changed from starting to crashed
2016-08-21T05:14:56.148890+00:00 heroku[web.1]: Process exited with status 1
Anybody has any idea how to fix this?
Problem solved - I have some unresolved dependency issue that I didn't found when running locally in dev mode
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