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.
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 am new in Heroku and currently building an app with react (Node.js).
While I was able to push successfully my master branch to Heroku and Heroku confirms my app is deployed successfully, yet, the app is not deployed despite that is shows below deploy success message: "Deploy to Heroku".
Below is the error log in Heroku:
2022-02-08T00:45:18.702341+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T00:45:18.702341+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-02-08T00:45:18.702341+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-02-08T00:45:18.702342+00:00 app[web.1]: }
2022-02-08T00:45:18.924415+00:00 heroku[web.1]: Process exited with status 1
2022-02-08T00:45:19.739614+00:00 heroku[web.1]: State changed from starting to crashed
2022-02-08T00:45:31.255261+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=haksuly1movieapp.herokuapp.com request_id=05cc8ef9-baa5-4af8-8167-ab18ec9fc909 fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
2022-02-08T00:45:31.413269+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=haksuly1movieapp.herokuapp.com request_id=83016251-e4f0-4bf0-87d0-39ecb39ddd3f fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
2022-02-08T00:46:20.928808+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=haksuly1movieapp.herokuapp.com request_id=d243ef5c-56d8-4e22-b095-f3915e338c90 fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
2022-02-08T00:46:21.142923+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=haksuly1movieapp.herokuapp.com request_id=49b1447a-2058-40c8-b85f-6934e1854ebb fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
Below is the error log from CLI:
2022-02-08T00:45:12.986742+00:00 app[web.1]: ^
2022-02-08T00:45:12.986743+00:00 app[web.1]:
2022-02-08T00:45:12.986744+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-02-08T00:45:12.986744+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-02-08T00:45:12.986745+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T00:45:12.986745+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-02-08T00:45:12.986746+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-02-08T00:45:12.986746+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-02-08T00:45:12.986746+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-02-08T00:45:12.986746+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-02-08T00:45:12.986747+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-02-08T00:45:12.986747+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T00:45:12.986747+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-02-08T00:45:12.986748+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-02-08T00:45:12.986748+00:00 app[web.1]: }
2022-02-08T00:45:13.178543+00:00 heroku[web.1]: Process exited with status 1
2022-02-08T00:45:13.264905+00:00 heroku[web.1]: State changed from starting to crashed
2022-02-08T00:45:13.273816+00:00 heroku[web.1]: State changed from crashed to starting
2022-02-08T00:45:15.956822+00:00 heroku[web.1]: Starting process with command `npm start`
2022-02-08T00:45:18.232060+00:00 app[web.1]:
2022-02-08T00:45:18.232080+00:00 app[web.1]: > movie_api#1.0.0 start
2022-02-08T00:45:18.232081+00:00 app[web.1]: > node index.js
2022-02-08T00:45:18.232081+00:00 app[web.1]:
2022-02-08T00:45:18.702302+00:00 app[web.1]: node:internal/modules/cjs/loader:1183
2022-02-08T00:45:18.702328+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-02-08T00:45:18.702329+00:00 app[web.1]: ^
2022-02-08T00:45:18.702330+00:00 app[web.1]:
2022-02-08T00:45:18.702336+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-02-08T00:45:18.702337+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-02-08T00:45:18.702338+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T00:45:18.702338+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-02-08T00:45:18.702338+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-02-08T00:45:18.702339+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-02-08T00:45:18.702340+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-02-08T00:45:18.702340+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-02-08T00:45:18.702340+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-02-08T00:45:18.702341+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T00:45:18.702341+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-02-08T00:45:18.702341+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-02-08T00:45:18.702342+00:00 app[web.1]: }
2022-02-08T00:45:18.924415+00:00 heroku[web.1]: Process exited with status 1
2022-02-08T00:45:19.739614+00:00 heroku[web.1]: State changed from starting to crashed
2022-02-08T00:45:31.255261+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=haksuly1movieapp.herokuapp.com request_id=05cc8ef9-baa5-4af8-8167-ab18ec9fc909 fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
2022-02-08T00:45:31.413269+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=haksuly1movieapp.herokuapp.com request_id=83016251-e4f0-4bf0-87d0-39ecb39ddd3f fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
2022-02-08T00:46:20.928808+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=haksuly1movieapp.herokuapp.com request_id=d243ef5c-56d8-4e22-b095-f3915e338c90 fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
2022-02-08T00:46:21.142923+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=haksuly1movieapp.herokuapp.com request_id=49b1447a-2058-40c8-b85f-6934e1854ebb fwd="88.130.53.4" dyno= connect= service= status=503 bytes= protocol=https
2022-02-08T01:06:56.000000+00:00 app[api]: Build started by user hakeemkayodesulyman#gmail.com
2022-02-08T01:07:18.099531+00:00 app[api]: Deploy 759fe937 by user hakeemkayodesulyman#gmail.com
2022-02-08T01:07:18.099531+00:00 app[api]: Release v17 created by user hakeemkayodesulyman#gmail.com
2022-02-08T01:07:18.394025+00:00 heroku[web.1]: State changed from crashed to starting
2022-02-08T01:07:21.000000+00:00 app[api]: Build succeeded
2022-02-08T01:07:21.034913+00:00 heroku[web.1]: Starting process with command `npm start`
2022-02-08T01:07:22.192406+00:00 app[web.1]:
2022-02-08T01:07:22.192420+00:00 app[web.1]: > movie_api#1.0.0 start
2022-02-08T01:07:22.192420+00:00 app[web.1]: > node index.js
2022-02-08T01:07:22.192420+00:00 app[web.1]:
2022-02-08T01:07:22.590438+00:00 app[web.1]: node:internal/modules/cjs/loader:1183
2022-02-08T01:07:22.590456+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-02-08T01:07:22.590456+00:00 app[web.1]: ^
2022-02-08T01:07:22.590457+00:00 app[web.1]:
2022-02-08T01:07:22.590458+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-02-08T01:07:22.590458+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-02-08T01:07:22.590459+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T01:07:22.590459+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-02-08T01:07:22.590459+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-02-08T01:07:22.590460+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-02-08T01:07:22.590460+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-02-08T01:07:22.590460+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-02-08T01:07:22.590460+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-02-08T01:07:22.590460+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T01:07:22.590461+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-02-08T01:07:22.590461+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-02-08T01:07:22.590461+00:00 app[web.1]: }
2022-02-08T01:07:22.717250+00:00 heroku[web.1]: Process exited with status 1
2022-02-08T01:07:22.786581+00:00 heroku[web.1]: State changed from starting to crashed
2022-02-08T01:07:22.825527+00:00 heroku[web.1]: State changed from crashed to starting
2022-02-08T01:07:25.399388+00:00 heroku[web.1]: Starting process with command `npm start`
2022-02-08T01:07:26.987095+00:00 app[web.1]:
2022-02-08T01:07:26.987107+00:00 app[web.1]: > movie_api#1.0.0 start
2022-02-08T01:07:26.987107+00:00 app[web.1]: > node index.js
2022-02-08T01:07:26.987108+00:00 app[web.1]:
2022-02-08T01:07:27.610704+00:00 app[web.1]: node:internal/modules/cjs/loader:1183
2022-02-08T01:07:27.610728+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2022-02-08T01:07:27.610729+00:00 app[web.1]: ^
2022-02-08T01:07:27.610730+00:00 app[web.1]:
2022-02-08T01:07:27.610731+00:00 app[web.1]: Error: /app/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
2022-02-08T01:07:27.610731+00:00 app[web.1]: at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2022-02-08T01:07:27.610732+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T01:07:27.610733+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2022-02-08T01:07:27.610733+00:00 app[web.1]: at Module.require (node:internal/modules/cjs/loader:1005:19)
2022-02-08T01:07:27.610733+00:00 app[web.1]: at require (node:internal/modules/cjs/helpers:102:18)
2022-02-08T01:07:27.610733+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/bcrypt/bcrypt.js:6:16)
2022-02-08T01:07:27.610734+00:00 app[web.1]: at Module._compile (node:internal/modules/cjs/loader:1101:14)
2022-02-08T01:07:27.610734+00:00 app[web.1]: at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2022-02-08T01:07:27.610734+00:00 app[web.1]: at Module.load (node:internal/modules/cjs/loader:981:32)
2022-02-08T01:07:27.610735+00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
2022-02-08T01:07:27.610735+00:00 app[web.1]: code: 'ERR_DLOPEN_FAILED'
2022-02-08T01:07:27.610735+00:00 app[web.1]: }
2022-02-08T01:07:27.789789+00:00 heroku[web.1]: Process exited with status 1
2022-02-08T01:07:27.876090+00:00 heroku[web.1]: State changed from starting to crashed
I have tried all tricks including many suggested here but it has not been helpful.
Of course, my package.json has this script. "start": "node index.js",
Could anyone help with a precise solution?
npm uninstall bcrypt
npm install bcryptjs
npm install bcrypt
All Good! nodejs v16.16.0
The issue was probably connected the caches in the Node_Modules. I fixed this issue by running this in the terminal:
$ git rm -r --cached .
$ git add .
$ git commit -m "fixed untracked files"
Use bcryptjs instead of bcrypt
$ npm uninstall bcrypt
$ npm install bcryptjs
Regarding the answers that involve using bcryptjs! Make sure you also change the require statement(s) to accurately reflect bcryptjs instead of bcrypt.
$ npm uninstall bcrypt
$ npm install bcryptjs
Above code is what you would need to run in the server component of your app!
Below is the code in the applicable files that require bcrypt but will now require bcryptjs
const <name> = require('bcryptjs');
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.
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?
hello i created an app based on a tutorial that works properly on my local. I use a sqlite in memory database (for development) and when i deploy i get the following error. Please tell me what details (i couldnt put the full log it was detected as spam) you need i am a newbie in node/hapi and heroku. THank you.
2020-03-27T13:21:21.337440+00:00 app[web.1]: /app/lib/models/index.js:7
2020-03-27T13:21:21.337489+00:00 app[web.1]: const dbSettings = Settings[Settings.env].db;
2020-03-27T13:21:21.337490+00:00 app[web.1]: ^
2020-03-27T13:21:21.337498+00:00 app[web.1]:
2020-03-27T13:21:21.337506+00:00 app[web.1]: TypeError: Cannot read property 'db' of undefined
2020-03-27T13:21:21.337507+00:00 app[web.1]: at Object. (/app/lib/models/index.js:7:43)
2020-03-27T13:21:21.337507+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1158:30)
2020-03-27T13:21:21.337514+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
2020-03-27T13:21:21.337515+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1002:32)
2020-03-27T13:21:21.337516+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:901:14)
2020-03-27T13:21:21.337516+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1044:19)
2020-03-27T13:21:21.337516+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:77:18)
2020-03-27T13:21:21.337516+00:00 app[web.1]: at Object. (/app/lib/controllers/home.js:3:16)
2020-03-27T13:21:21.337517+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1158:30)
2020-03-27T13:21:21.337517+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
2020-03-27T13:21:21.337517+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1002:32)
2020-03-27T13:21:21.337517+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:901:14)
2020-03-27T13:21:21.337518+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1044:19)
2020-03-27T13:21:21.337518+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:77:18)
2020-03-27T13:21:21.337518+00:00 app[web.1]: at Object. (/app/lib/routes.js:3:14)
2020-03-27T13:21:21.337518+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:1158:30)
2020-03-27T13:21:21.337519+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
2020-03-27T13:21:21.337519+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:1002:32)
2020-03-27T13:21:21.337519+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:901:14)
2020-03-27T13:21:21.337519+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:1044:19)
2020-03-27T13:21:21.337520+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:77:18)
2020-03-27T13:21:21.337520+00:00 app[web.1]: at Object. (/app/server.js:7:16)
2020-03-27T13:21:25.387251+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=serene-scrubland-72461.herokuapp.com request_id=34632d56-e244-40de-b954-6854c2b08c7f fwd="86.250.193.144" dyno= connect= service= status=503 bytes= protocol=https
2020-03-27T13:21:25.624603+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=serene-scrubland-72461.herokuapp.com request_id=123f2cd5-5644-4b53-97d3-183248ef8a7a fwd="86.250.193.144" dyno= connect= service= status=503 bytes= protocol=https
solved by using postgres addons from heroku