Heroku at=error code=H10 desc="App crashed" - node.js

I'm having this error, when I try to access my api on heroku
I have project with nodejs, typescript, typeORM and using database with Postgresql.
link for my project: https://github.com/WesleyIsr4/tarefas_api/tree/main/tasks_api
2021-03-24T23:42:04.841420+00:00 heroku[web.1]: Starting process with command `npm start`
2021-03-24T23:42:06.805718+00:00 app[web.1]:
2021-03-24T23:42:06.805731+00:00 app[web.1]: > tasks_api#0.0.1 start /app
2021-03-24T23:42:06.805731+00:00 app[web.1]: > node src/index.ts
2021-03-24T23:42:06.805731+00:00 app[web.1]:
2021-03-24T23:42:06.871406+00:00 app[web.1]: (node:21) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
2021-03-24T23:42:06.871407+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2021-03-24T23:42:06.874166+00:00 app[web.1]: /app/src/index.ts:1
2021-03-24T23:42:06.874166+00:00 app[web.1]: import "reflect-metadata";
2021-03-24T23:42:06.874167+00:00 app[web.1]: ^^^^^^
2021-03-24T23:42:06.874167+00:00 app[web.1]:
2021-03-24T23:42:06.874168+00:00 app[web.1]: SyntaxError: Cannot use import statement outside a module
2021-03-24T23:42:06.874168+00:00 app[web.1]: at wrapSafe (internal/modules/cjs/loader.js:979:16)
2021-03-24T23:42:06.874169+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1027:27)
2021-03-24T23:42:06.874169+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
2021-03-24T23:42:06.874170+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:928:32)
2021-03-24T23:42:06.874170+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14)
2021-03-24T23:42:06.874171+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
2021-03-24T23:42:06.874171+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-03-24T23:42:06.889434+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-03-24T23:42:06.889834+00:00 app[web.1]: npm ERR! errno 1
2021-03-24T23:42:06.896276+00:00 app[web.1]: npm ERR! tasks_api#0.0.1 start: `node src/index.ts`
2021-03-24T23:42:06.896419+00:00 app[web.1]: npm ERR! Exit status 1
2021-03-24T23:42:06.896567+00:00 app[web.1]: npm ERR!
2021-03-24T23:42:06.896657+00:00 app[web.1]: npm ERR! Failed at the tasks_api#0.0.1 start script.
2021-03-24T23:42:06.896771+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-03-24T23:42:06.905764+00:00 app[web.1]:
2021-03-24T23:42:06.906023+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-03-24T23:42:06.906187+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-03-24T23_42_06_897Z-debug.log
2021-03-24T23:42:06.952487+00:00 heroku[web.1]: Process exited with status 1
2021-03-24T23:42:07.022497+00:00 heroku[web.1]: State changed from starting to crashed
2021-03-24T23:42:07.716132+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=taskedapi.herokuapp.com request_id=cb3a7f47-103e-408d-874b-c0e3466eead5 fwd="177.37.210.66" dyno= connect= service= status=503 bytes= protocol=https
2021-03-24T23:42:08.350324+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=taskedapi.herokuapp.com request_id=ead9cb26-9b21-4d6e-9630-70b13306d777 fwd="177.37.210.66" dyno= connect= service= status=503 bytes= protocol=https

Node can't run typescript (.ts) files. You're going to need to either:
use something like ts-node to compile the files
compile your .ts files to .js as part of your deployment steps

For everybody parachuted here...
In your package.json you have to change your scripts to:
"scripts": {
"build": "tsc",
"start": "node dist/server.js",
...other scripts may be put here too
},
When deployed, heroku will execute build script, transpiling your typescript to javascript, then it will execute start script.
Note that start script will run your .js file, not the original .ts.
It is important to say that start script must point to your server.js file found in dist folder(created during deployiment), not to server.ts from your src folder.
Heroku docs say you have to put a main key in package.json too as shown:
"main": "server.js",
"license": "MIT",
"scripts": {
...
My answer may be late for the OP, but complement #Jim's answer

Related

Application error - I'm getting an error message after deployment to Heroku even though my app works fine in development

I tried to publish my app to Heroku but I got the below error message:
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail
I checked the logs and got the below info which I cannot decipher:
(node:40446) SyntaxError Plugin: heroku: /home/me/.local/share/heroku/config.json: Unexpected end of JSON input
module: #oclif/config#1.17.0
task: runHook prerun
plugin: heroku
root: /snap/heroku/4076
See more details with DEBUG=*
2021-09-20T22:05:15.905073+00:00 app[api]: Deploy 17474356 by user me.me#myemail.com
2021-09-20T22:05:15.922889+00:00 app[api]: Scaled to web#1:Free by user me.me#myemail.com
2021-09-20T22:05:17.000000+00:00 app[api]: Build succeeded
2021-09-20T22:05:22.406972+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-20T22:05:23.782304+00:00 app[web.1]:
2021-09-20T22:05:23.782323+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2021-09-20T22:05:23.782323+00:00 app[web.1]: > node server.js
2021-09-20T22:05:23.782323+00:00 app[web.1]:
2021-09-20T22:05:24.264339+00:00 app[web.1]: /app/server.js:4
2021-09-20T22:05:24.264356+00:00 app[web.1]: const path = requier("path");
2021-09-20T22:05:24.264357+00:00 app[web.1]: ^
2021-09-20T22:05:24.264357+00:00 app[web.1]:
2021-09-20T22:05:24.264358+00:00 app[web.1]: ReferenceError: requier is not defined
2021-09-20T22:05:24.264358+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2021-09-20T22:05:24.264359+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-20T22:05:24.264359+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-20T22:05:24.264360+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-20T22:05:24.264360+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-20T22:05:24.264360+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-09-20T22:05:24.264361+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-09-20T22:05:24.276266+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-20T22:05:24.276629+00:00 app[web.1]: npm ERR! errno 1
2021-09-20T22:05:24.285403+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2021-09-20T22:05:24.285546+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-20T22:05:24.285701+00:00 app[web.1]: npm ERR!
2021-09-20T22:05:24.285813+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2021-09-20T22:05:24.285905+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-20T22:05:24.304319+00:00 app[web.1]:
2021-09-20T22:05:24.307416+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-20T22:05:24.307459+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-09-20T22_05_24_286Z-debug.log
2021-09-20T22:05:24.477472+00:00 heroku[web.1]: Process exited with status 1
2021-09-20T22:05:24.608841+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-20T22:05:24.616776+00:00 heroku[web.1]: State changed from crashed to starting
2021-09-20T22:05:30.615650+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-20T22:05:32.154416+00:00 app[web.1]:
2021-09-20T22:05:32.154432+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2021-09-20T22:05:32.154432+00:00 app[web.1]: > node server.js
2021-09-20T22:05:32.154433+00:00 app[web.1]:
2021-09-20T22:05:32.491951+00:00 app[web.1]: /app/server.js:4
2021-09-20T22:05:32.491970+00:00 app[web.1]: const path = requier("path");
2021-09-20T22:05:32.491970+00:00 app[web.1]: ^
2021-09-20T22:05:32.491970+00:00 app[web.1]:
2021-09-20T22:05:32.491971+00:00 app[web.1]: ReferenceError: requier is not defined
2021-09-20T22:05:32.491971+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2021-09-20T22:05:32.491971+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-20T22:05:32.491972+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-20T22:05:32.491972+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-20T22:05:32.491972+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-20T22:05:32.491975+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-09-20T22:05:32.491975+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-09-20T22:05:32.502469+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-20T22:05:32.504151+00:00 app[web.1]: npm ERR! errno 1
2021-09-20T22:05:32.507359+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2021-09-20T22:05:32.507361+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-20T22:05:32.507362+00:00 app[web.1]: npm ERR!
2021-09-20T22:05:32.507362+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2021-09-20T22:05:32.507363+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-20T22:05:32.517624+00:00 app[web.1]:
2021-09-20T22:05:32.517629+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-20T22:05:32.517630+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-09-20T22_05_32_508Z-debug.log
2021-09-20T22:05:32.654009+00:00 heroku[web.1]: Process exited with status 1
2021-09-20T22:05:32.790052+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-20T22:10:11.627061+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-thicket-06601.herokuapp.com request_id=0c6e85f7-f539-406d-a7fa-9d92a88ea7de fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:10:12.524329+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pure-thicket-06601.herokuapp.com request_id=c9282c5e-54aa-4735-802d-fd782041837a fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:13:28.000000+00:00 app[api]: Build started by user me.me#myemail.com
2021-09-20T22:15:44.820687+00:00 app[api]: Deploy d8ef6129 by user me.me#myemail.com
2021-09-20T22:15:44.820687+00:00 app[api]: Release v4 created by user me.me#myemail.com
2021-09-20T22:15:45.198887+00:00 heroku[web.1]: State changed from crashed to starting
2021-09-20T22:15:46.000000+00:00 app[api]: Build succeeded
2021-09-20T22:15:51.404944+00:00 heroku[web.1]: Starting process with command `npm start`
2021-09-20T22:15:52.687305+00:00 app[web.1]:
2021-09-20T22:15:52.687323+00:00 app[web.1]: > contact-keeper#1.0.0 start /app
2021-09-20T22:15:52.687323+00:00 app[web.1]: > node server.js
2021-09-20T22:15:52.687324+00:00 app[web.1]:
2021-09-20T22:15:53.120246+00:00 app[web.1]: /app/server.js:4
2021-09-20T22:15:53.120260+00:00 app[web.1]: const path = requier("path");
2021-09-20T22:15:53.120260+00:00 app[web.1]: ^
2021-09-20T22:15:53.120261+00:00 app[web.1]:
2021-09-20T22:15:53.120262+00:00 app[web.1]: ReferenceError: requier is not defined
2021-09-20T22:15:53.120262+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:4:14)
2021-09-20T22:15:53.120263+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14)
2021-09-20T22:15:53.120263+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
2021-09-20T22:15:53.120264+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:937:32)
2021-09-20T22:15:53.120264+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12)
2021-09-20T22:15:53.120265+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
2021-09-20T22:15:53.120265+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2021-09-20T22:15:53.132041+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2021-09-20T22:15:53.132277+00:00 app[web.1]: npm ERR! errno 1
2021-09-20T22:15:53.143479+00:00 app[web.1]: npm ERR! contact-keeper#1.0.0 start: `node server.js`
2021-09-20T22:15:53.143539+00:00 app[web.1]: npm ERR! Exit status 1
2021-09-20T22:15:53.143612+00:00 app[web.1]: npm ERR!
2021-09-20T22:15:53.143669+00:00 app[web.1]: npm ERR! Failed at the contact-keeper#1.0.0 start script.
2021-09-20T22:15:53.143714+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-09-20T22:15:53.156377+00:00 app[web.1]:
2021-09-20T22:15:53.156477+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2021-09-20T22:15:53.156529+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2021-09-20T22_15_53_144Z-debug.log
2021-09-20T22:15:53.320983+00:00 heroku[web.1]: Process exited with status 1
2021-09-20T22:15:53.393003+00:00 heroku[web.1]: State changed from starting to crashed
2021-09-20T22:16:11.040791+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-thicket-06601.herokuapp.com request_id=fcca437f-5d66-44db-a8dc-8bb638db78ac fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:16:11.928866+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pure-thicket-06601.herokuapp.com request_id=d12c938a-0a91-4947-8d10-6af6f31a7b9f fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
2021-09-20T22:17:36.704916+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pure-thicket-06601.herokuapp.com request_id=5ed37742-5272-486e-b762-323e16c53cf1 fwd="89.211.153.133" dyno= connect= service= status=503 bytes= protocol=https
Any idea what went wrong? Everything worked perfectly fine in localhost but now even locally I'm having problems after deployment.
There is a spelling error. Replace
const path = requier("path");
with
const path = require("path");
and deploy it again to see if it works.

Error when deploying Express.js + React.js project to heroku

I finished working on my website, and everything works great locally, but I get an error when deploying to heroku.
Some background:
Back-end server was built using this tutorial (Express.js + Sequelize + PostgreSQL): https://www.djamware.com/post/5b56a6cc80aca707dd4f65a9/nodejs-expressjs-sequelizejs-and-postgresql-restful-api
Front-end was built by using npx create-react-app command.
Deploying issue
Now, for deploying I used the tutorial at https://www.freecodecamp.org/news/deploy-a-react-node-app-to/ and created a new Postgres Database on heroku (and that's it).
When I try to view the site at "xxxxx.herokuapp.com" this "Application error" message:
So i tried running the heroku logs --tail command and this was the message I got:
heroku logs --tail -a grades-il
2020-10-09T15:26:15.091358+00:00 heroku[web.1]: Starting process with command `npm start`
2020-10-09T15:26:17.586004+00:00 heroku[web.1]: Process exited with status 1
2020-10-09T15:26:17.623057+00:00 heroku[web.1]: State changed from starting to crashed
2020-10-09T15:26:17.333545+00:00 app[web.1]:
2020-10-09T15:26:17.333566+00:00 app[web.1]: > node-sequelize#0.0.0 start /app
2020-10-09T15:26:17.333567+00:00 app[web.1]: > node ./bin/www
2020-10-09T15:26:17.333567+00:00 app[web.1]:
2020-10-09T15:26:17.505070+00:00 app[web.1]: internal/modules/cjs/loader.js:834
2020-10-09T15:26:17.505072+00:00 app[web.1]: throw err;
2020-10-09T15:26:17.505072+00:00 app[web.1]: ^
2020-10-09T15:26:17.505072+00:00 app[web.1]:
2020-10-09T15:26:17.505073+00:00 app[web.1]: Error: Cannot find module './school'
2020-10-09T15:26:17.505073+00:00 app[web.1]: Require stack:
2020-10-09T15:26:17.505073+00:00 app[web.1]: - /app/controllers/index.js
2020-10-09T15:26:17.505074+00:00 app[web.1]: - /app/routes/index.js
2020-10-09T15:26:17.505074+00:00 app[web.1]: - /app/app.js
2020-10-09T15:26:17.505074+00:00 app[web.1]: - /app/bin/www
2020-10-09T15:26:17.505075+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
2020-10-09T15:26:17.505075+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:687:27)
2020-10-09T15:26:17.505075+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:903:19)
2020-10-09T15:26:17.505075+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2020-10-09T15:26:17.505076+00:00 app[web.1]: at Object.<anonymous> (/app/controllers/index.js:1:16)
2020-10-09T15:26:17.505076+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-10-09T15:26:17.505076+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-10-09T15:26:17.505076+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-10-09T15:26:17.505077+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-10-09T15:26:17.505077+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:903:19) {
2020-10-09T15:26:17.505077+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2020-10-09T15:26:17.505077+00:00 app[web.1]: requireStack: [
2020-10-09T15:26:17.505078+00:00 app[web.1]: '/app/controllers/index.js',
2020-10-09T15:26:17.505078+00:00 app[web.1]: '/app/routes/index.js',
2020-10-09T15:26:17.505078+00:00 app[web.1]: '/app/app.js',
2020-10-09T15:26:17.505079+00:00 app[web.1]: '/app/bin/www'
2020-10-09T15:26:17.505079+00:00 app[web.1]: ]
2020-10-09T15:26:17.505079+00:00 app[web.1]: }
2020-10-09T15:26:17.515720+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-10-09T15:26:17.515920+00:00 app[web.1]: npm ERR! errno 1
2020-10-09T15:26:17.520600+00:00 app[web.1]: npm ERR! node-sequelize#0.0.0 start: `node ./bin/www`
2020-10-09T15:26:17.520705+00:00 app[web.1]: npm ERR! Exit status 1
2020-10-09T15:26:17.520815+00:00 app[web.1]: npm ERR!
2020-10-09T15:26:17.520929+00:00 app[web.1]: npm ERR! Failed at the node-sequelize#0.0.0 start script.
2020-10-09T15:26:17.521011+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-10-09T15:26:17.525367+00:00 app[web.1]:
2020-10-09T15:26:17.525509+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-10-09T15:26:17.525583+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-10-09T15_26_17_521Z-debug.log
2020-10-09T15:27:20.340920+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=xxxxx.herokuapp.com request_id=320b7a37-e1e9-4974-92b0-b98e6af2667a fwd="79.177.39.29" dyno= connect= service= status=503 bytes= protocol=http
2020-10-09T15:27:20.850485+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=xxxxx.herokuapp.com request_id=23268c05-28cf-4fc4-9aa7-8ef69befa2b2 fwd="79.177.39.29" dyno= connect= service= status=503 bytes= protocol=http
So if you have any idea how to fix this, I'd appreciate your help.
Thanks!
Thanks to Mohit Karekar I solved the problem by just changing
require('./school');
to
require('./School');
and that's it.

How to find out what's wrong with heroku?

I created a very simple nodejs application, the link is here https://bitbucket.org/danclaudiu95/mongo-nodejs-0.git
I only have an index.js file where I have
router.get('/', (req, res) => {
res.send('Hello World')
})
and commited and pushed changes to heroku, the app is here https://git.heroku.com/nodejs-mongo-cc.git, it tells me "Method Not Allowed"
and here https://nodejs-mongo-cc.herokuapp.com/ is tels Application error
I receive this log when I run heroku logs --tail I have this log
2019-12-08T18:55:25.296312+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-08T18:55:25.296314+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-08T18:55:25.296316+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
2019-12-08T18:55:25.296318+00:00 app[web.1]: }
2019-12-08T18:55:25.304642+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-08T18:55:25.305127+00:00 app[web.1]: npm ERR! errno 1
2019-12-08T18:55:25.306936+00:00 app[web.1]: npm ERR! mongo-nodejs-0#1.0.0 start: `node server.js`
2019-12-08T18:55:25.307220+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-08T18:55:25.307516+00:00 app[web.1]: npm ERR!
2019-12-08T18:55:25.307771+00:00 app[web.1]: npm ERR! Failed at the mongo-nodejs-0#1.0.0 start script.
2019-12-08T18:55:25.308011+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-08T18:55:25.316870+00:00 app[web.1]:
2019-12-08T18:55:25.317055+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-08T18:55:25.317209+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-08T18_55_25_308Z-debug.log
2019-12-08T18:55:25.382554+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-08T18:55:25.387301+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-08T18:55:25.361045+00:00 heroku[web.1]: Process exited with status 1
2019-12-08T18:55:26.985866+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-08T18:55:28.903449+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-08T18:55:28.773773+00:00 app[web.1]:
2019-12-08T18:55:28.773792+00:00 app[web.1]: > mongo-nodejs-0#1.0.0 start /app
2019-12-08T18:55:28.773795+00:00 app[web.1]: > node server.js
2019-12-08T18:55:28.773797+00:00 app[web.1]:
2019-12-08T18:55:28.821433+00:00 app[web.1]: internal/modules/cjs/loader.js:800
2019-12-08T18:55:28.821437+00:00 app[web.1]: throw err;
2019-12-08T18:55:28.821443+00:00 app[web.1]: ^
2019-12-08T18:55:28.821445+00:00 app[web.1]:
2019-12-08T18:55:28.821447+00:00 app[web.1]: Error: Cannot find module 'express'
2019-12-08T18:55:28.821449+00:00 app[web.1]: Require stack:
2019-12-08T18:55:28.821451+00:00 app[web.1]: - /app/server.js
2019-12-08T18:55:28.821452+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
2019-12-08T18:55:28.821454+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:690:27)
2019-12-08T18:55:28.821456+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2019-12-08T18:55:28.821457+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-12-08T18:55:28.821459+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:1:17)
2019-12-08T18:55:28.821460+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-08T18:55:28.821462+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-08T18:55:28.821463+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-08T18:55:28.821465+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-08T18:55:28.821467+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-08T18:55:28.821468+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-08T18:55:28.821470+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
2019-12-08T18:55:28.821471+00:00 app[web.1]: }
2019-12-08T18:55:28.827415+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-08T18:55:28.827775+00:00 app[web.1]: npm ERR! errno 1
2019-12-08T18:55:28.828849+00:00 app[web.1]: npm ERR! mongo-nodejs-0#1.0.0 start: `node server.js`
2019-12-08T18:55:28.829049+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-08T18:55:28.829213+00:00 app[web.1]: npm ERR!
2019-12-08T18:55:28.829353+00:00 app[web.1]: npm ERR! Failed at the mongo-nodejs-0#1.0.0 start script.
2019-12-08T18:55:28.829473+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-08T18:55:28.836399+00:00 app[web.1]:
2019-12-08T18:55:28.836520+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-08T18:55:28.836621+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-08T18_55_28_830Z-debug.log
2019-12-08T18:55:28.884330+00:00 heroku[web.1]: Process exited with status 1
2019-12-08T18:56:13.485700+00:00 app[api]: Release v4 created by user dan_tomuta#yahoo.com
2019-12-08T18:56:13.485700+00:00 app[api]: Set DATABASE_URL config vars by user dan_tomuta#yahoo.com
2019-12-08T18:56:14.534382+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-08T18:56:16.302004+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-08T18:56:20.368258+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-08T18:56:20.348173+00:00 heroku[web.1]: Process exited with status 1
2019-12-08T18:56:20.213878+00:00 app[web.1]:
2019-12-08T18:56:20.213966+00:00 app[web.1]: > mongo-nodejs-0#1.0.0 start /app
2019-12-08T18:56:20.213969+00:00 app[web.1]: > node server.js
2019-12-08T18:56:20.213972+00:00 app[web.1]:
2019-12-08T18:56:20.279308+00:00 app[web.1]: internal/modules/cjs/loader.js:800
2019-12-08T18:56:20.279312+00:00 app[web.1]: throw err;
2019-12-08T18:56:20.279314+00:00 app[web.1]: ^
2019-12-08T18:56:20.279316+00:00 app[web.1]:
2019-12-08T18:56:20.279318+00:00 app[web.1]: Error: Cannot find module 'express'
2019-12-08T18:56:20.279320+00:00 app[web.1]: Require stack:
2019-12-08T18:56:20.279326+00:00 app[web.1]: - /app/server.js
2019-12-08T18:56:20.279344+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
2019-12-08T18:56:20.279346+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:690:27)
2019-12-08T18:56:20.279349+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2019-12-08T18:56:20.279352+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-12-08T18:56:20.279354+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:1:17)
2019-12-08T18:56:20.279356+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-08T18:56:20.279359+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-08T18:56:20.279361+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-08T18:56:20.279363+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-08T18:56:20.279365+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-08T18:56:20.279367+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-08T18:56:20.279369+00:00 app[web.1]: requireStack: [ '/app/server.js' ]
2019-12-08T18:56:20.279371+00:00 app[web.1]: }
2019-12-08T18:56:20.284895+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-08T18:56:20.285175+00:00 app[web.1]: npm ERR! errno 1
2019-12-08T18:56:20.286349+00:00 app[web.1]: npm ERR! mongo-nodejs-0#1.0.0 start: `node server.js`
2019-12-08T18:56:20.286533+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-08T18:56:20.286713+00:00 app[web.1]: npm ERR!
2019-12-08T18:56:20.286852+00:00 app[web.1]: npm ERR! Failed at the mongo-nodejs-0#1.0.0 start script.
2019-12-08T18:56:20.287001+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-08T18:56:20.293863+00:00 app[web.1]:
2019-12-08T18:56:20.294005+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-08T18:56:20.294099+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-08T18_56_20_287Z-debug.log
2019-12-08T18:59:25.447421+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nodejs-mongo-cc.herokuapp.com request_id=78ed9049-8e85-459d-9579-6a64cdf4a09a fwd="178.138.96.80" dyno= connect= service= status=503 bytes= protocol=https
2019-12-08T18:59:26.012326+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nodejs-mongo-cc.herokuapp.com request_id=9f49a46a-ecef-43c3-9f14-e9143c147a5d fwd="178.138.96.80" dyno= connect= service= status=503 bytes= protocol=https
2019-12-08T18:59:26.700786+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nodejs-mongo-cc.herokuapp.com request_id=b623338f-0d3d-4ec9-8fa5-6947eaa8ca89 fwd="178.138.96.80" dyno= connect= service= status=503 bytes= protocol=https
2019-12-08T18:59:27.151441+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nodejs-mongo-cc.herokuapp.com request_id=25967892-0116-4f11-b1e4-fbd051814247 fwd="178.138.96.80" dyno= connect= service= status=503 bytes= protocol=https
2019-12-08T18:59:28.370508+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=nodejs-mongo-cc.herokuapp.com request_id=5627ecd7-98ef-45a1-8475-3b4dfdd91893 fwd="178.138.96.80" dyno= connect= service= status=503 bytes= protocol=https
2019-12-08T18:59:28.869557+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=nodejs-mongo-cc.herokuapp.com request_id=0afb7f92-58ad-4496-84bc-40fc47ebf3b9 fwd="178.138.96.80" dyno= connect= service= status=503 bytes= protocol=https
Can anyone help me, please?
Make sure you follow the guide in the Heroku website for node.js. You can find it here - Getting Started on Heroku with Node.js. Make sure you add a file that has a name Procfile in you project and type in - web: node index.js.
And also do not forget to have a listener in your js file - app.listen(process.env.PORT);.
After you pushed your file from git to Heroku, go to the Heroku website, log in and you will see your app published (might take a while to build).

Why googleapis node module is not found in heroku?

I have a chatbot made using Node Js. It uses "googleapis". It works fine when I create a server from my laptop. But I uploaded files to github and used heroku as server. I get "Application Error" on the web address provided by heroku to access the app. How to fix it.
WARNING: See https://github.com/lorenwest/node-config/wiki/Strict-Mode
2019-11-20T07:55:39.730004+00:00 app[web.1]:
internal/modules/cjs/loader.js:800 2019-11-20T07:55:39.730026+00:00
app[web.1]: throw err; 2019-11-20T07:55:39.730028+00:00 app[web.1]: ^
2019-11-20T07:55:39.730030+00:00 app[web.1]:
2019-11-20T07:55:39.730032+00:00 app[web.1]: Error: Cannot find module
'googleapis' 2019-11-20T07:55:39.730034+00:00 app[web.1]: Require
stack: 2019-11-20T07:55:39.730036+00:00 app[web.1]: - /app/app.js
2019-11-20T07:55:39.730045+00:00 app[web.1]: at
Function.Module._resolveFilename
(internal/modules/cjs/loader.js:797:15)
2019-11-20T07:55:39.730047+00:00 app[web.1]: at Function.Module._load
(internal/modules/cjs/loader.js:690:27)
2019-11-20T07:55:39.730050+00:00 app[web.1]: at Module.require
(internal/modules/cjs/loader.js:852:19)
2019-11-20T07:55:39.730052+00:00 app[web.1]: at require
(internal/modules/cjs/helpers.js:74:18)
2019-11-20T07:55:39.730053+00:00 app[web.1]: at Object.
(/app/app.js:23:16) 2019-11-20T07:55:39.730055+00:00 app[web.1]: at
Module._compile (internal/modules/cjs/loader.js:959:30)
2019-11-20T07:55:39.730057+00:00 app[web.1]: at
Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-11-20T07:55:39.730059+00:00 app[web.1]: at Module.load
(internal/modules/cjs/loader.js:815:32)
2019-11-20T07:55:39.730061+00:00 app[web.1]: at Function.Module._load
(internal/modules/cjs/loader.js:727:14)
2019-11-20T07:55:39.730063+00:00 app[web.1]: at
Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-11-20T07:55:39.730065+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-11-20T07:55:39.730067+00:00 app[web.1]: requireStack: [
'/app/app.js' ] 2019-11-20T07:55:39.730069+00:00 app[web.1]: }
2019-11-20T07:55:39.737402+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-11-20T07:55:39.737824+00:00 app[web.1]: npm ERR! errno 1
2019-11-20T07:55:39.739094+00:00 app[web.1]: npm ERR!
messenger-get-started#1.0.0 start: node app.js
2019-11-20T07:55:39.739328+00:00 app[web.1]: npm ERR! Exit status 1
2019-11-20T07:55:39.739554+00:00 app[web.1]: npm ERR!
2019-11-20T07:55:39.739763+00:00 app[web.1]: npm ERR! Failed at the
messenger-get-started#1.0.0 start script.
2019-11-20T07:55:39.739994+00:00 app[web.1]: npm ERR! This is probably
not a problem with npm. There is likely additional logging output
above. 2019-11-20T07:55:39.747500+00:00 app[web.1]:
2019-11-20T07:55:39.747681+00:00 app[web.1]: npm ERR! A complete log
of this run can be found in: 2019-11-20T07:55:39.747852+00:00
app[web.1]: npm ERR!
/app/.npm/_logs/2019-11-20T07_55_39_740Z-debug.log
2019-11-20T07:55:39.842413+00:00 heroku[web.1]: State changed from
starting to crashed 2019-11-20T07:55:39.831194+00:00 heroku[web.1]:
Process exited with status 1 2019-11-20T08:47:20.684024+00:00
heroku[router]: at=error code=H10 desc="App crashed" method=GET
path="/" host=mukupukuu.herokuapp.com
request_id=9bf7f838-97ee-4776-9517-b9c0b530241d fwd="49.244.16.204"
dyno= connect= service= status=503 bytes= protocol=https
2019-11-20T08:47:32.344155+00:00 heroku[router]: at=error code=H10
desc="App crashed" method=GET path="/favicon.ico"
host=mukupukuu.herokuapp.com
request_id=ace83680-39e1-489d-a50c-b1c6811f24ce fwd="49.244.16.204"
dyno= connect= service= status=503 bytes= protocol=https
Make sure to include the GoogleApi npm package in the package.json This helps Heroku fetch and install the required dependencies on the server where your application is deployed.
You can add the package and version manually to package.json
OR
A better alternative is to run npm install --save googleapis

heroku node cannot find module 'app/console'

I was adding AWS S3 on my nodejs, this is the first time i use this.
when i run my app, it had an error
2018-10-03T11:56:13.843291+00:00 app[web.1]: sh: 1: nodemon: not found
2018-10-03T11:56:13.827644+00:00 app[web.1]: > nodemon server.js
2018-10-03T11:56:13.854413+00:00 app[web.1]: npm ERR! file sh
2018-10-03T11:56:13.854859+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-10-03T11:56:13.855269+00:00 app[web.1]: npm ERR! errno ENOENT
2018-10-03T11:56:13.855634+00:00 app[web.1]: npm ERR! syscall spawn
2018-10-03T11:56:13.858988+00:00 app[web.1]: npm ERR! novel-ist-api#1.0.0 start: `nodemon server.js`
2018-10-03T11:56:13.859985+00:00 app[web.1]: npm ERR!
2018-10-03T11:56:13.860414+00:00 app[web.1]: npm ERR! Failed at the novel-ist-api#1.0.0 start script.
2018-10-03T11:56:13.859363+00:00 app[web.1]: npm ERR! spawn ENOENT
2018-10-03T11:56:13.901352+00:00 app[web.1]:
2018-10-03T11:56:13.860881+00:00 app[web.1]: npm ERR! This is probably not a problem
with npm. There is likely additional logging output above.
2018-10-03T11:56:13.902089+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-10-03T11_56_13_866Z-debug.log
2018-10-03T11:56:13.901742+00:00 app[web.1]: npm ERR! A complete log of this run can
be found in:
2018-10-03T11:56:30.126455+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-hamlet-21755.herokuapp.com request_id=2db274ec-3b56-4a75-ad11-0fecf2e93821 fwd="180.243.188.17" dyno= connect= service= status=503 bytes= protocol=https
2018-10-03T11:56:31.865897+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=morning-hamlet-21755.herokuapp.com request_id=d54be99d-3257-49c7-ae9a-d3a8ced50d74 fwd="180.243.188.17" dyno= connect= service= status=503 bytes= protocol=https
then i tried to run heroku run node console, it gives me this:
module.js:550
throw err;
^
Error: Cannot find module '/app/console'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
i dont know how to fix this

Resources