My app works locally, but when trying to deploy I get code=H10. I have tried looking up code=H10 failures, but they all see to lead to changes with process.env.PORT changes, which I have already done in various ways.
This is my first time deploying to heroku, so sorry if I am missing some important information.
Any advice will be much appreciated.
My logs:
2021-05-16T23:27:11.291289+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:27:11.291289+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:27:11.291289+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:27:11.291290+00:00 app[web.1]: requireStack: []
2021-05-16T23:27:11.291290+00:00 app[web.1]: }
2021-05-16T23:27:11.341722+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:27:11.432934+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:27:55.798013+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=3428bce1-739d-47ed-9205-9859475e0e22 fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
2021-05-16T23:33:49.000000+00:00 app[api]: Build started by user joshuamacleod#live.com
2021-05-16T23:36:06.038437+00:00 app[api]: Release v17 created by user joshuamacleod#live.com
2021-05-16T23:36:06.038437+00:00 app[api]: Deploy 31855de1 by user joshuamacleod#live.com
2021-05-16T23:36:06.264449+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:36:07.000000+00:00 app[api]: Build succeeded
2021-05-16T23:36:19.886178+00:00 heroku[web.1]: Starting process with command `node build/server.js`
2021-05-16T23:36:22.175404+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:36:22.175424+00:00 app[web.1]: throw err;
2021-05-16T23:36:22.175425+00:00 app[web.1]: ^
2021-05-16T23:36:22.175425+00:00 app[web.1]:
2021-05-16T23:36:22.175426+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2021-05-16T23:36:22.175426+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:36:22.175427+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:36:22.175427+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:36:22.175428+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:36:22.175428+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:36:22.175429+00:00 app[web.1]: requireStack: []
2021-05-16T23:36:22.175429+00:00 app[web.1]: }
2021-05-16T23:36:22.240102+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:36:22.322859+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:36:50.313742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=0e8e0047-c98d-4126-9008-c50c7d927320 fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
2021-05-16T23:43:04.802415+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:43:19.981689+00:00 heroku[web.1]: Starting process with command `node build/server.js`
2021-05-16T23:43:22.004092+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:43:22.004127+00:00 app[web.1]: throw err;
2021-05-16T23:43:22.004127+00:00 app[web.1]: ^
2021-05-16T23:43:22.004128+00:00 app[web.1]:
2021-05-16T23:43:22.004128+00:00 app[web.1]: Error: Cannot find module '/app/build/server.js'
2021-05-16T23:43:22.004129+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:43:22.004129+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:43:22.004130+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
2021-05-16T23:43:22.004130+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2021-05-16T23:43:22.004130+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:43:22.004131+00:00 app[web.1]: requireStack: []
2021-05-16T23:43:22.004131+00:00 app[web.1]: }
2021-05-16T23:43:22.064674+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:43:22.121461+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:56:01.000000+00:00 app[api]: Build started by user joshuamacleod#live.com
2021-05-16T23:58:17.578622+00:00 app[api]: Release v18 created by user joshuamacleod#live.com
2021-05-16T23:58:17.578622+00:00 app[api]: Deploy 09023d82 by user joshuamacleod#live.com
2021-05-16T23:58:17.959761+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:58:19.000000+00:00 app[api]: Build succeeded
2021-05-16T23:58:35.537730+00:00 heroku[web.1]: Starting process with command `node server.js`
2021-05-16T23:58:38.809616+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:58:38.809639+00:00 app[web.1]: throw err;
2021-05-16T23:58:38.809640+00:00 app[web.1]: ^
2021-05-16T23:58:38.809640+00:00 app[web.1]:
2021-05-16T23:58:38.809640+00:00 app[web.1]: Error: Cannot find module '/Users/joshua/makers/thenewslab/news-server/db'
2021-05-16T23:58:38.809641+00:00 app[web.1]: Require stack:
2021-05-16T23:58:38.809641+00:00 app[web.1]: - /app/routes/api/users.js
2021-05-16T23:58:38.809641+00:00 app[web.1]: - /app/server.js
2021-05-16T23:58:38.809642+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19)
2021-05-16T23:58:38.809643+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:93:18)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api/users.js:5:12)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1109:14)
2021-05-16T23:58:38.809644+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:989:32)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:829:14)
2021-05-16T23:58:38.809645+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19) {
2021-05-16T23:58:38.809646+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:58:38.809646+00:00 app[web.1]: requireStack: [ '/app/routes/api/users.js', '/app/server.js' ]
2021-05-16T23:58:38.809648+00:00 app[web.1]: }
2021-05-16T23:58:38.902832+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:58:38.974809+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:58:38.986788+00:00 heroku[web.1]: State changed from crashed to starting
2021-05-16T23:58:50.650040+00:00 heroku[web.1]: Starting process with command `node server.js`
2021-05-16T23:58:52.992272+00:00 app[web.1]: node:internal/modules/cjs/loader:944
2021-05-16T23:58:52.992286+00:00 app[web.1]: throw err;
2021-05-16T23:58:52.992286+00:00 app[web.1]: ^
2021-05-16T23:58:52.992286+00:00 app[web.1]:
2021-05-16T23:58:52.992287+00:00 app[web.1]: Error: Cannot find module '/Users/joshua/makers/thenewslab/news-server/db'
2021-05-16T23:58:52.992287+00:00 app[web.1]: Require stack:
2021-05-16T23:58:52.992287+00:00 app[web.1]: - /app/routes/api/users.js
2021-05-16T23:58:52.992288+00:00 app[web.1]: - /app/server.js
2021-05-16T23:58:52.992288+00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:941:15)
2021-05-16T23:58:52.992288+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:774:27)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:93:18)
2021-05-16T23:58:52.992289+00:00 app[web.1]: at Object.<anonymous> (/app/routes/api/users.js:5:12)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1109:14)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:989:32)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:829:14)
2021-05-16T23:58:52.992290+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1013:19) {
2021-05-16T23:58:52.992294+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-05-16T23:58:52.992294+00:00 app[web.1]: requireStack: [ '/app/routes/api/users.js', '/app/server.js' ]
2021-05-16T23:58:52.992294+00:00 app[web.1]: }
2021-05-16T23:58:53.061937+00:00 heroku[web.1]: Process exited with status 1
2021-05-16T23:58:53.120732+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-16T23:59:37.345240+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=thenewslab.herokuapp.com request_id=76cb051f-7ecc-451e-93cc-50f56beac59a fwd="46.69.82.216" dyno= connect= service= status=503 bytes= protocol=https
My server:
const express = require('express')
const bodyParser = require('body-parser')
const cors = require('cors')
const passport = require("passport");
const users = require("./routes/api/users");
const path = require("path");
const db = require('./db')
const articleRouter = require('./routes/article-router')
const app = express()
const server = process.env.PORT || 5000
app.use(bodyParser.urlencoded({
extended: true
}))
app.use(cors())
app.use(bodyParser.json())
app.use(passport.initialize());
app.use(express.static(path.join(__dirname, "client", "build")))
require("./config/passport")(passport);
db.on('error', console.error.bind(console, 'MongoDB connection error:'))
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "client", "build", "index.html"));
});
app.use('/api', articleRouter)
app.use("/api/users", users);
app.listen(server, () => console.log(`Server running on port ${server}`))
My package.json:
{
"name": "news-server",
"version": "1.0.0",
"engines": {
"node": ">= 14.15.5",
"npm": "6.14.11"
},
"description": "",
"main": "server.js",
"scripts": {
"start": "node server.js",
"heroku-postbuild": "cd news-front && npm install --only=dev && npm install && npm run build"
}
My Procfile:
web: node server.js
A Procfile is not always necessary to deploy Node.js apps to Heroku, however, your package.json is very very important. The package.json file should include the modules to be installed. Which is missing.
The logs clearly say code: 'MODULE_NOT_FOUND', which means node_modules/ are missing.
You might have node_modules/ in your local system, but Heroku ignores it. It takes package.json and freshly starts to download it.
Heroku runs something like this. It Deletes node_modules/ then runs "npm install" then "node server.js"
For you, I would advice to always save your node_modules/ to package.json. This can be done while installing modules easily by adding --save
To debug this, do
"npm install --save express cors passport"
You can do this or do
"npm i --save express"
"npm i --save cors"
"npm i --save passport"
It is then showing me ./routes/api/users - I hope you have it.
Related
I have tried searched and looked at others answer to similar question but non of them worked, please help.
Here is the error I received in console.
2022-05-17T21:18:16.026881+00:00 app[web.1]: at Module._compile
(node:internal/modules/cjs/loader:1105:14)
2022-05-17T21:18:16.026881+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)2022-05-17T21:18:16.026881+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-17T21:18:16.026881+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-05-17T21:18:16.026882+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-05-17T21:18:16.026882+00:00 app[web.1]: }
2022-05-17T21:18:16.139886+00:00 heroku[web.1]: Process exited with status 1
2022-05-17T21:18:16.292720+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-17T22:52:21.606239+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=livelyapp.herokuapp.com request_id=92863718-fff6-4dd4-925c-10ccc9a6a53c fwd="197.210.29.29" dyno= connect= service= status=503 bytes= protocol=https
2022-05-17T22:52:23.232426+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=livelyapp.herokuapp.com request_id=a170ab83-06b5-4ee8-b82e-fd1df99e9630 fwd="197.210.29.29" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T00:37:21.346570+00:00 heroku[web.1]: State changed from crashed to starting
2022-05-18T00:37:29.343314+00:00 heroku[web.1]: Starting process with command `node server.js`
2022-05-18T00:37:31.070030+00:00 app[web.1]: node:internal/modules/cjs/loader:1189
2022-05-18T00:37:31.070042+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-05-18T00:37:31.070042+00:00 app[web.1]: ^
2022-05-18T00:37:31.070043+00:00 app[web.1]:
2022-05-18T00:37:31.070043+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-05-18T00:37:31.070043+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
2022-05-18T00:37:31.070044+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T00:37:31.070044+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-18T00:37:31.070044+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-18T00:37:31.070045+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-18T00:37:31.070045+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-05-18T00:37:31.070045+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14)
2022-05-18T00:37:31.070046+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)2022-05-18T00:37:31.070046+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T00:37:31.070047+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-05-18T00:37:31.070047+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-05-18T00:37:31.070047+00:00 app[web.1]: }
2022-05-18T00:37:31.193029+00:00 heroku[web.1]: Process exited with status 1
2022-05-18T00:37:31.261105+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-18T07:45:19.567202+00:00 heroku[web.1]: State changed from crashed to starting
2022-05-18T07:45:22.394875+00:00 heroku[web.1]: Starting process with command `node server.js`
2022-05-18T07:45:24.058143+00:00 app[web.1]: node:internal/modules/cjs/loader:1189
2022-05-18T07:45:24.058159+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-05-18T07:45:24.058159+00:00 app[web.1]: ^
2022-05-18T07:45:24.058159+00:00 app[web.1]:
2022-05-18T07:45:24.058160+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-05-18T07:45:24.058160+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
2022-05-18T07:45:24.058160+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T07:45:24.058161+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-18T07:45:24.058161+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-18T07:45:24.058161+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-18T07:45:24.058161+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-05-18T07:45:24.058162+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14)
2022-05-18T07:45:24.058162+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)2022-05-18T07:45:24.058162+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T07:45:24.058162+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-05-18T07:45:24.058163+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-05-18T07:45:24.058163+00:00 app[web.1]: }
2022-05-18T07:45:24.223717+00:00 heroku[web.1]: Process exited with status 1
2022-05-18T07:45:24.311901+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-18T08:48:08.000000+00:00 app[api]: Build started by user livelyjay45#gmail.com
2022-05-18T08:48:28.808471+00:00 app[api]: Deploy ed74bec9 by user livelyjay45#gmail.com
2022-05-18T08:48:28.808471+00:00 app[api]: Release v9 created by user livelyjay45#gmail.com
2022-05-18T08:48:30.000000+00:00 app[api]: Build succeeded
2022-05-18T08:48:30.172466+00:00 heroku[web.1]: State changed from crashed to starting
2022-05-18T08:48:32.484549+00:00 heroku[web.1]: Starting process with command `node server.js`
2022-05-18T08:48:33.492277+00:00 app[web.1]: node:internal/modules/cjs/loader:1189
2022-05-18T08:48:33.492293+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-05-18T08:48:33.492293+00:00 app[web.1]: ^
2022-05-18T08:48:33.492294+00:00 app[web.1]:
2022-05-18T08:48:33.492294+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-05-18T08:48:33.492294+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
2022-05-18T08:48:33.492295+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T08:48:33.492295+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-18T08:48:33.492295+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-18T08:48:33.492296+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-18T08:48:33.492296+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-05-18T08:48:33.492297+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14)
2022-05-18T08:48:33.492297+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)2022-05-18T08:48:33.492297+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T08:48:33.492297+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-05-18T08:48:33.492298+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-05-18T08:48:33.492298+00:00 app[web.1]: }
2022-05-18T08:48:33.596666+00:00 heroku[web.1]: Process exited with status 1
2022-05-18T08:48:33.791426+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-18T08:48:33.794828+00:00 heroku[web.1]: State changed from crashed to starting
2022-05-18T08:48:36.318183+00:00 heroku[web.1]: Starting process with command `node server.js`
2022-05-18T08:48:38.022044+00:00 app[web.1]: node:internal/modules/cjs/loader:1189
2022-05-18T08:48:38.022059+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-05-18T08:48:38.022059+00:00 app[web.1]: ^
2022-05-18T08:48:38.022060+00:00 app[web.1]:
2022-05-18T08:48:38.022060+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-05-18T08:48:38.022060+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
2022-05-18T08:48:38.022061+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T08:48:38.022061+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-05-18T08:48:38.022062+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-05-18T08:48:38.022062+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-05-18T08:48:38.022063+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-05-18T08:48:38.022063+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1105:14)
2022-05-18T08:48:38.022063+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)2022-05-18T08:48:38.022064+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-05-18T08:48:38.022064+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-05-18T08:48:38.022064+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-05-18T08:48:38.022065+00:00 app[web.1]: }
2022-05-18T08:48:38.144327+00:00 heroku[web.1]: Process exited with status 1
2022-05-18T08:48:38.213751+00:00 heroku[web.1]: State changed from starting to crashed
2022-05-18T08:49:24.961992+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=livelyapp.herokuapp.com request_id=741a7893-e3a0-457a-bf07-8b0be1faacd9 fwd="197.210.29.29" dyno= connect= service= status=503 bytes= protocol=https
2022-05-18T08:49:26.356963+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=livelyapp.herokuapp.com request_id=9f8fd422-208c-4767-aa81-a96e9e7110e2 fwd="197.210.29.29" dyno= connect= service= status=503 bytes= protocol=https
And here is my package.json file, is something missing?
{
"name": "react-project",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server",
"dev": "nodemon server"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.1",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"date-fns": "^2.28.0",
"dotenv": "^16.0.0",
"express": "^4.17.3",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.2.10",
"nodemon": "^2.0.15",
"uuid": "^8.3.2"
}
}
and my server.js file
require('dotenv').config()
const express = require('express')
const cors = require('cors')
const path = require('path')
const corsOrigin = require('./config/allowedCors')
const { eventLoggerFile } = require('./middleware/eventLoger')
const router = require('./routes/root')
const employee = require('./routes/employee/index')
const register = require('./routes/users/index')
const errorHandler = require('./middleware/errorHandler')
const verifyJWT = require('./middleware/verifyJwt')
const cookieParser = require('cookie-parser');
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(eventLoggerFile)
app.use(express.static(path.join(__dirname, 'public')))
app.use(cookieParser())
app.use(cors(corsOrigin))
app.use('/', router)
app.use('/api', verifyJWT, employee)
app.use('/ap', register)
app.all('*', (req, res) => {
res.status(404).send('not found, error')
})
app.use(errorHandler)
const PORT = process.env.PORT || 5000
app.listen(PORT, () => {
console.log(`server started on port ${PORT}`)
})
Please what am I doing wrong, I have been trying to resolve it since yesterday and nothing has change till now.
I'm having trouble deploying my Node/Postgres App to Heroku. When I run my deploy script, the build completes, but after opening the database connection, an error is thrown for a missing module. My Procfile contains web: node main.js and my start script in the package.json states "start": "node main".
Below I am attaching a copy of the heroku logs and the code in main.js which is in the root directory.
Heroku Logs
2021-01-09T23:23:17.000000+00:00 app[api]: Build started by user ********#gmail.com
2021-01-09T23:23:34.407776+00:00 app[api]: Release v17 created by user ********#gmail.com
2021-01-09T23:23:34.407776+00:00 app[api]: Deploy 664cb125 by user ********#gmail.com
2021-01-09T23:23:34.721923+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-09T23:23:35.000000+00:00 app[api]: Build succeeded
2021-01-09T23:23:38.364250+00:00 heroku[web.1]: Starting process with command `node main.js`
2021-01-09T23:23:41.218590+00:00 app[web.1]: Opening database connection to shoppies-nominator
2021-01-09T23:23:41.615336+00:00 app[web.1]: internal/modules/cjs/loader.js:818
2021-01-09T23:23:41.615350+00:00 app[web.1]: throw err;
2021-01-09T23:23:41.615350+00:00 app[web.1]: ^
2021-01-09T23:23:41.615351+00:00 app[web.1]:
2021-01-09T23:23:41.615351+00:00 app[web.1]: Error: Cannot find module 'volleyball'
2021-01-09T23:23:41.615352+00:00 app[web.1]: Require stack:
2021-01-09T23:23:41.615353+00:00 app[web.1]: - /app/server/index.js
2021-01-09T23:23:41.615353+00:00 app[web.1]: - /app/main.js
2021-01-09T23:23:41.615355+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
2021-01-09T23:23:41.615356+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:667:27)
2021-01-09T23:23:41.615357+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:887:19)
2021-01-09T23:23:41.615358+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2021-01-09T23:23:41.615358+00:00 app[web.1]: at Object.<anonymous> (/app/server/index.js:3:20)
2021-01-09T23:23:41.615359+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:999:30)
2021-01-09T23:23:41.615359+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
2021-01-09T23:23:41.615360+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:863:32)
2021-01-09T23:23:41.615360+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-01-09T23:23:41.615361+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:887:19)
2021-01-09T23:23:41.615362+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2021-01-09T23:23:41.615362+00:00 app[web.1]: at Object.<anonymous> (/app/main.js:4:13)
2021-01-09T23:23:41.615362+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:999:30)
2021-01-09T23:23:41.615363+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
2021-01-09T23:23:41.615363+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:863:32)
2021-01-09T23:23:41.615364+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-01-09T23:23:41.615365+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2021-01-09T23:23:41.615366+00:00 app[web.1]: at internal/main/run_main_module.js:17:47 {
2021-01-09T23:23:41.615366+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2021-01-09T23:23:41.615367+00:00 app[web.1]: requireStack: [ '/app/server/index.js', '/app/main.js' ]
2021-01-09T23:23:41.615367+00:00 app[web.1]: }
2021-01-09T23:23:41.703611+00:00 heroku[web.1]: Process exited with status 1
2021-01-09T23:23:41.752561+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-09T23:58:53.127855+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shoppies-nominator.herokuapp.com request_id=010f5699-f805-4ce0-92a5-74225a0eb610 fwd="69.141.164.13" dyno= connect= service= status=503 bytes= protocol=https
main.js
const {db} = require('./server/db')
const app = require('./server')
const PORT = process.env.PORT || 5409
db.sync()
.then(() => {
console.log('db synced')
app.listen(PORT, (e) => {
if (e) throw (e)
console.log(`Listening on port ${PORT}`)
})
})
Any ideas?
I am deploying a fullstack react/express app to Heroku, it has managed to deploy. There are multiple errors in the Heroku logs which I have cannot seem to understand/figure out. I also have a Procfile with web: node server.js
I have tried to clear cache - delete node_modules and package.json then npm install again but this has not made a difference.
Heroku Logs
2020-11-15T13:08:12.713935+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:08:12.713935+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:08:12.713935+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:08:12.783289+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:08:12.818062+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:08:12.826070+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:08:21.448256+00:00 heroku[web.1]: Starting process with command `node server.js`
2020-11-15T13:08:24.324135+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:08:24.324170+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:08:24.324175+00:00 app[web.1]: ^
2020-11-15T13:08:24.324175+00:00 app[web.1]:
2020-11-15T13:08:24.324180+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2020-11-15T13:08:24.324185+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:08:24.324185+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:08:24.324190+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:08:24.324190+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:08:24.324190+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:08:24.324191+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:08:24.324192+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:08:24.324196+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:08:24.418110+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:08:24.454083+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:23:24.786742+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=obscure-journey-43421.herokuapp.com request_id=aa6c54d3-cfe3-4f74-b4c5-93018f00ba97 fwd="84.9.66.95" dyno= connect= service= status=503 bytes= protocol=https
2020-11-15T13:23:26.240301+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=obscure-journey-43421.herokuapp.com request_id=ec07ad1c-091f-4e53-b50d-9632b66dd2d4 fwd="84.9.66.95" dyno= connect= service= status=503 bytes= protocol=https
2020-11-15T13:27:28.000000+00:00 app[api]: Build started by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.458958+00:00 app[api]: Deploy 12d81f3b by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.458958+00:00 app[api]: Release v12 created by user peterjameslewis4#hotmail.com
2020-11-15T13:29:08.625747+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:29:09.000000+00:00 app[api]: Build succeeded
2020-11-15T13:29:17.927953+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-15T13:29:20.083139+00:00 app[web.1]:
2020-11-15T13:29:20.083155+00:00 app[web.1]: > movie-database#1.0.0 start /app
2020-11-15T13:29:20.083155+00:00 app[web.1]: > node server.js
2020-11-15T13:29:20.083155+00:00 app[web.1]:
2020-11-15T13:29:20.795200+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:29:20.795248+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:29:20.795250+00:00 app[web.1]: ^
2020-11-15T13:29:20.795250+00:00 app[web.1]:
2020-11-15T13:29:20.795251+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2020-11-15T13:29:20.795252+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:29:20.795254+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:29:20.795254+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:29:20.795255+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:29:20.795256+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:29:20.795257+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:29:20.795258+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:29:20.810114+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-15T13:29:20.810451+00:00 app[web.1]: npm ERR! errno 1
2020-11-15T13:29:20.817598+00:00 app[web.1]: npm ERR! movie-database#1.0.0 start: `node server.js`
2020-11-15T13:29:20.817850+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-15T13:29:20.818099+00:00 app[web.1]: npm ERR!
2020-11-15T13:29:20.818312+00:00 app[web.1]: npm ERR! Failed at the movie-database#1.0.0 start script.
2020-11-15T13:29:20.818490+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-15T13:29:20.827750+00:00 app[web.1]:
2020-11-15T13:29:20.828041+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-15T13:29:20.828210+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-15T13_29_20_819Z-debug.log
2020-11-15T13:29:20.877545+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:29:20.913439+00:00 heroku[web.1]: State changed from starting to crashed
2020-11-15T13:29:20.917070+00:00 heroku[web.1]: State changed from crashed to starting
2020-11-15T13:29:33.460653+00:00 heroku[web.1]: Starting process with command `npm start`
2020-11-15T13:29:36.844587+00:00 app[web.1]:
2020-11-15T13:29:36.844630+00:00 app[web.1]: > movie-database#1.0.0 start /app
2020-11-15T13:29:36.844631+00:00 app[web.1]: > node server.js
2020-11-15T13:29:36.844631+00:00 app[web.1]:
2020-11-15T13:29:38.011159+00:00 app[web.1]: /app/node_modules/mongoose/lib/connection.js:669
2020-11-15T13:29:38.011219+00:00 app[web.1]: throw new MongooseError('The `uri` parameter to `openUri()` must be a ' +
2020-11-15T13:29:38.011220+00:00 app[web.1]: ^
2020-11-15T13:29:38.011220+00:00 app[web.1]:
2020-11-15T13:29:38.011224+00:00 app[web.1]: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
2020-11-15T13:29:38.011224+00:00 app[web.1]: at NativeConnection.Connection.openUri (/app/node_modules/mongoose/lib/connection.js:669:11)
2020-11-15T13:29:38.011225+00:00 app[web.1]: at /app/node_modules/mongoose/lib/index.js:342:10
2020-11-15T13:29:38.011226+00:00 app[web.1]: at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:9:12)
2020-11-15T13:29:38.011226+00:00 app[web.1]: at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:341:10)
2020-11-15T13:29:38.011226+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:18:10)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1015:30)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
2020-11-15T13:29:38.011227+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:879:32)
2020-11-15T13:29:38.011228+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:724:14)
2020-11-15T13:29:38.011228+00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
2020-11-15T13:29:38.011229+00:00 app[web.1]: at internal/main/run_main_module.js:17:47
2020-11-15T13:29:38.046555+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-15T13:29:38.047758+00:00 app[web.1]: npm ERR! errno 1
2020-11-15T13:29:38.059446+00:00 app[web.1]: npm ERR! movie-database#1.0.0 start: node server.js
2020-11-15T13:29:38.059681+00:00 app[web.1]: npm ERR! Exit status 1
2020-11-15T13:29:38.059955+00:00 app[web.1]: npm ERR!
2020-11-15T13:29:38.060192+00:00 app[web.1]: npm ERR! Failed at the movie-database#1.0.0 start script.
2020-11-15T13:29:38.060432+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-15T13:29:38.096793+00:00 app[web.1]:
2020-11-15T13:29:38.097273+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-15T13:29:38.097587+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-15T13_29_38_061Z-debug.log
2020-11-15T13:29:38.193702+00:00 heroku[web.1]: Process exited with status 1
2020-11-15T13:29:38.242866+00:00 heroku[web.1]: State changed from starting to crashed
Server.js
const express = require('express');
const app = express();
const path = require('path');
const cors = require('cors');
const port = process.env.PORT || 5000;
const dotenv = require('dotenv');
const mongoose = require('mongoose');
// Auth Routes
const authRoute = require('./routes/auth');
dotenv.config();
//Connect to DB
mongoose.connect(process.env.DB_CONNECT,
{ useNewUrlParser: true, useUnifiedTopology: true },
() => console.log('connected to DB!')
);
// Serve static files from the React app
app.use(express.static(path.join(__dirname, 'client/build/')));
// Middleware
app.use(express.json());
app.use(cors());
// Put all API endpoints under '/api'
app.use('/api', authRoute)
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/client/build/index.html'));
});
app.listen(port, () => {
console.log(`Listening on port ${port}`);
});
Package.json
{
"name": "movie-database",
"version": "1.0.0",
"description": "Small application created with React.js, react router and the movie database to showcase all latest, upcoming and most popular movies.",
"main": "server.js",
"scripts": {
"start": "node server.js",
"heroku-postbuild": "cd client && npm install && npm run build"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.0.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"joi": "^17.3.0",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.20",
"mongoose": "^5.10.12",
"nodemon": "^2.0.6",
"password-generator": "^2.3.2",
"serve": "^11.3.2"
}
}
I cannot figure out what is going wrong?
i'm deploying my first app on heroku, i pushed the code on GitHub, add Heroku keys(because ), created the heroku app on terminal and finally git push heroku master.
The app is very basic, but it doesn't work, and i can't even find a decent log information to work with!
This is the long log that i found.
Hope someone could help me!
2019-12-06T00:11:00.862870+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-06T00:11:00.862872+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-06T00:11:00.862874+00:00 app[web.1]: requireStack: [ '/app/src/app.js' ]
2019-12-06T00:11:00.862876+00:00 app[web.1]: }
2019-12-06T00:11:00.870032+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-06T00:11:00.871330+00:00 app[web.1]: npm ERR! errno 1
2019-12-06T00:11:00.871733+00:00 app[web.1]: npm ERR! 1-Heroku#1.0.0 start: `node src/app.js`
2019-12-06T00:11:00.872684+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-06T00:11:00.872690+00:00 app[web.1]: npm ERR!
2019-12-06T00:11:00.872695+00:00 app[web.1]: npm ERR! Failed at the 1-Heroku#1.0.0 start script.
2019-12-06T00:11:00.872698+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-06T00:11:02.538864+00:00 app[web.1]:
2019-12-06T00:11:02.542433+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-06T00:11:02.542703+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-06T00_11_00_875Z-debug.log
2019-12-06T00:11:02.625046+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-06T00:11:02.614891+00:00 heroku[web.1]: Process exited with status 1
2019-12-06T00:18:05.000000+00:00 app[api]: Build started by user cristiano.piscioneri.dev#gmail.com
2019-12-06T00:18:24.105108+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=b779201e-bb33-420a-9aea-cd67d026040e fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
2019-12-06T00:18:48.614900+00:00 app[api]: Deploy c57e0dc3 by user cristiano.piscioneri.dev#gmail.com
2019-12-06T00:18:48.614900+00:00 app[api]: Release v4 created by user cristiano.piscioneri.dev#gmail.com
2019-12-06T00:18:48.892841+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-06T00:18:49.000000+00:00 app[api]: Build succeeded
2019-12-06T00:18:52.277413+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-06T00:18:55.506035+00:00 app[web.1]:
2019-12-06T00:18:55.506063+00:00 app[web.1]: > 1-Heroku#1.0.0 start /app
2019-12-06T00:18:55.506065+00:00 app[web.1]: > node src/app.js
2019-12-06T00:18:55.506067+00:00 app[web.1]:
2019-12-06T00:18:55.809888+00:00 app[web.1]: internal/modules/cjs/loader.js:800
2019-12-06T00:18:55.809932+00:00 app[web.1]: throw err;
2019-12-06T00:18:55.809934+00:00 app[web.1]: ^
2019-12-06T00:18:55.809936+00:00 app[web.1]:
2019-12-06T00:18:55.809939+00:00 app[web.1]: Error: Cannot find module 'hbs'
2019-12-06T00:18:55.809941+00:00 app[web.1]: Require stack:
2019-12-06T00:18:55.809943+00:00 app[web.1]: - /app/src/app.js
2019-12-06T00:18:55.809945+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
2019-12-06T00:18:55.809947+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:690:27)
2019-12-06T00:18:55.809950+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2019-12-06T00:18:55.809952+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-12-06T00:18:55.809954+00:00 app[web.1]: at Object.<anonymous> (/app/src/app.js:5:13)
2019-12-06T00:18:55.809956+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-06T00:18:55.809958+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-06T00:18:55.809960+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-06T00:18:55.809962+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-06T00:18:55.809964+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-06T00:18:55.809966+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-06T00:18:55.809968+00:00 app[web.1]: requireStack: [ '/app/src/app.js' ]
2019-12-06T00:18:55.809970+00:00 app[web.1]: }
2019-12-06T00:18:55.853916+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-06T00:18:55.854597+00:00 app[web.1]: npm ERR! errno 1
2019-12-06T00:18:55.858952+00:00 app[web.1]: npm ERR! 1-Heroku#1.0.0 start: `node src/app.js`
2019-12-06T00:18:55.859163+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-06T00:18:55.859694+00:00 app[web.1]: npm ERR!
2019-12-06T00:18:55.859697+00:00 app[web.1]: npm ERR! Failed at the 1-Heroku#1.0.0 start script.
2019-12-06T00:18:55.859764+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-06T00:18:55.917128+00:00 app[web.1]:
2019-12-06T00:18:55.917132+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-06T00:18:55.917135+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-06T00_18_55_860Z-debug.log
2019-12-06T00:18:56.015418+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-06T00:18:55.990556+00:00 heroku[web.1]: Process exited with status 1
2019-12-06T00:18:57.272264+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=1371d608-aa3d-4ada-94bb-cde5f9edfd69 fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
2019-12-06T00:21:46.461037+00:00 heroku[web.1]: State changed from crashed to starting
2019-12-06T00:21:49.272673+00:00 heroku[web.1]: Starting process with command `npm start`
2019-12-06T00:21:53.501754+00:00 heroku[web.1]: State changed from starting to crashed
2019-12-06T00:21:53.116284+00:00 app[web.1]:
2019-12-06T00:21:53.116306+00:00 app[web.1]: > 1-Heroku#1.0.0 start /app
2019-12-06T00:21:53.116308+00:00 app[web.1]: > node src/app.js
2019-12-06T00:21:53.116310+00:00 app[web.1]:
2019-12-06T00:21:53.306576+00:00 app[web.1]: internal/modules/cjs/loader.js:800
2019-12-06T00:21:53.306580+00:00 app[web.1]: throw err;
2019-12-06T00:21:53.306583+00:00 app[web.1]: ^
2019-12-06T00:21:53.306586+00:00 app[web.1]:
2019-12-06T00:21:53.306588+00:00 app[web.1]: Error: Cannot find module 'hbs'
2019-12-06T00:21:53.306591+00:00 app[web.1]: Require stack:
2019-12-06T00:21:53.306596+00:00 app[web.1]: - /app/src/app.js
2019-12-06T00:21:53.306598+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
2019-12-06T00:21:53.306600+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:690:27)
2019-12-06T00:21:53.306603+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:852:19)
2019-12-06T00:21:53.306605+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2019-12-06T00:21:53.306607+00:00 app[web.1]: at Object.<anonymous> (/app/src/app.js:5:13)
2019-12-06T00:21:53.306609+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:959:30)
2019-12-06T00:21:53.306611+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
2019-12-06T00:21:53.306613+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:815:32)
2019-12-06T00:21:53.306616+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:727:14)
2019-12-06T00:21:53.306618+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
2019-12-06T00:21:53.306620+00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2019-12-06T00:21:53.306622+00:00 app[web.1]: requireStack: [ '/app/src/app.js' ]
2019-12-06T00:21:53.306624+00:00 app[web.1]: }
2019-12-06T00:21:53.321267+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2019-12-06T00:21:53.321742+00:00 app[web.1]: npm ERR! errno 1
2019-12-06T00:21:53.324564+00:00 app[web.1]: npm ERR! 1-Heroku#1.0.0 start: `node src/app.js`
2019-12-06T00:21:53.324972+00:00 app[web.1]: npm ERR! Exit status 1
2019-12-06T00:21:53.325528+00:00 app[web.1]: npm ERR!
2019-12-06T00:21:53.326031+00:00 app[web.1]: npm ERR! Failed at the 1-Heroku#1.0.0 start script.
2019-12-06T00:21:53.326436+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-12-06T00:21:53.342561+00:00 app[web.1]:
2019-12-06T00:21:53.342869+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2019-12-06T00:21:53.343077+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2019-12-06T00_21_53_327Z-debug.log
2019-12-06T00:21:53.479134+00:00 heroku[web.1]: Process exited with status 1
2019-12-06T00:22:24.106302+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=fbd6f731-b6f7-49c1-b1ed-2373fd79d7d1 fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
2019-12-06T00:31:08.844509+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=c-neri-heroku.herokuapp.com request_id=f109e557-116b-4915-8c50-82520f635a42 fwd="151.32.4.219" dyno= connect= service= status=503 bytes= protocol=https
my app.js
const express = require('express')
const path = require('path')
const app = express()
const appRoute = require('./routes/app.js')
const hbs = require( 'hbs')
const port = process.env.PORT||3001
const publicPath = path.join(__dirname + '../../public')
const partialsPath = path.join(__dirname + '/template/partials')
const viewPath = path.join(__dirname + '/template/views')
//HBS
app.set('view engine', 'hbs')
app.set('views', viewPath)
hbs.registerPartials(partialsPath)
app.use(express.static(publicPath))
//ROUTES
app.use(appRoute)
app.listen(port)
my package.js script
"scripts": {
"build": "webpack",
"watch": "webpack --watch",
"dev": "nodemon src/app.js",
"start": "node src/app.js"
},
I am a newbie in heroku and node.js and I would like to get to know how these work. I tried the tutorial given by heroku. Everthing is fine until this step. I pushed and tried to open in on the web, but doesn't work. Logs said it cannot find the module, meanwhile I've installed it using npm.
I tried 3 times using different new clone but nonetheless none worked. I also copied all the index.js script given on the tutorial.
index:
const cool = require('cool-ascii-faces')
const express = require('express')
const path = require('path')
const PORT = process.env.PORT || 5000
express()
.use(express.static(path.join(__dirname, 'public')))
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'ejs')
.get('/', (req, res) => res.render('pages/index'))
.get('/cool', (req, res) => res.send(cool()))
.listen(PORT, () => console.log(`Listening on ${ PORT }`))
logs:
2019-05-09T09:56:08.000000+00:00 app[api]: Build succeeded
2019-05-09T09:56:08.892352+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2019-05-09T09:56:08.986034+00:00 heroku[web.1]: Process exited with status 143
2019-05-09T09:56:09.884923+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-05-09T09:56:11.789509+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-09T09:56:11.800910+00:00 heroku[web.1]: State changed from crashed to starting
2019-05-09T09:56:11.773890+00:00 heroku[web.1]: Process exited with status 1
2019-05-09T09:56:11.731995+00:00 app[web.1]: internal/modules/cjs/loader.js:584
2019-05-09T09:56:11.732041+00:00 app[web.1]: throw err;
2019-05-09T09:56:11.732043+00:00 app[web.1]: ^
2019-05-09T09:56:11.732044+00:00 app[web.1]:
2019-05-09T09:56:11.732045+00:00 app[web.1]: Error: Cannot find module 'cool-ascii-faces'
2019-05-09T09:56:11.732047+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
2019-05-09T09:56:11.732048+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:508:25)
2019-05-09T09:56:11.732049+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:637:17)
2019-05-09T09:56:11.732050+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:22:18)
2019-05-09T09:56:11.732052+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:1:76)
2019-05-09T09:56:11.732053+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:701:30)
2019-05-09T09:56:11.732054+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
2019-05-09T09:56:11.732055+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:600:32)
2019-05-09T09:56:11.732056+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
2019-05-09T09:56:11.732058+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:531:3)
2019-05-09T09:56:14.928577+00:00 heroku[web.1]: Starting process with command `node index.js`
2019-05-09T09:56:17.311684+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-09T09:56:17.291125+00:00 heroku[web.1]: Process exited with status 1
2019-05-09T09:56:17.224570+00:00 app[web.1]: internal/modules/cjs/loader.js:584
2019-05-09T09:56:17.224594+00:00 app[web.1]: throw err;
2019-05-09T09:56:17.224596+00:00 app[web.1]: ^
2019-05-09T09:56:17.224598+00:00 app[web.1]:
2019-05-09T09:56:17.224600+00:00 app[web.1]: Error: Cannot find module 'cool-ascii-faces'
2019-05-09T09:56:17.224601+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
2019-05-09T09:56:17.224603+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:508:25)
2019-05-09T09:56:17.224605+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:637:17)
2019-05-09T09:56:17.224609+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:22:18)
2019-05-09T09:56:17.224610+00:00 app[web.1]: at Object.<anonymous> (/app/index.js:1:76)
2019-05-09T09:56:17.224612+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:701:30)
2019-05-09T09:56:17.224614+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
2019-05-09T09:56:17.224615+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:600:32)
2019-05-09T09:56:17.224617+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
2019-05-09T09:56:17.224618+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:531:3)
2019-05-09T09:56:19.017142+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/cool" host=immense-oasis-20574.herokuapp.com request_id=b24f9916-5042-4b41-9034-e5421063b37f fwd="87.187.232.81" dyno= connect= service= status=503 bytes= protocol=https
2019-05-09T10:09:56.847796+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-oasis-20574.herokuapp.com request_id=62b8f104-be58-49f5-9b45-82603b0cc1a9 fwd="87.187.232.81" dyno= connect= service= status=503 bytes= protocol=https
You have to run npm install --save cool-ascii-faces.
Heroku get the packages from your package.json and not from the node_modules folder. You should actually never commit it by adding it to your .gitignore file.