0

Hi I am trying to deploy my backend app using heruko but whenever I try opening it i get an error page:enter image description here

naturally, I searched through stack overflow for solutions but non of them seemed to have worked. I think a possible issue is my Procfile, it is a custom one that was used in the end of this youtube video =>" https://www.youtube.com/watch?v=aibtHnbeuio&list=PL6QREj8te1P7VSwhrMf3D3Xt4V6_SRkhu&index=2 ". when surfing through potential fixes I did see some different Procfiles but weren't sure if any were of us.

my current Procfile:

web: npm run start

I think the main issue I need that needs to be solved is this error NPM_CONFIG_LOGLEVEL=error

in the following console output when pushing using the deployment steps on the heroku website

Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 371 bytes | 371.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:        
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        
remote: -----> Installing binaries
remote:        engines.node (package.json):  15.x
remote:        engines.npm (package.json):   unspecified (use default)
remote:        
remote:        Resolving node version 15.x...
remote:        Downloading and installing node 15.14.0...
remote:        Using default npm version: 7.7.6
remote:        
remote: -----> Restoring cache
remote:        Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote:        Module installation may take longer for this build
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules
remote:        
remote:        added 89 packages, and audited 90 packages in 2s
remote:        
remote:        11 packages are looking for funding
remote:          run `npm fund` for details
remote:        
remote:        found 0 vulnerabilities
remote:        
remote: -----> Build
remote:        
remote: -----> Caching build
remote:        - npm cache
remote:        
remote: -----> Pruning devDependencies
remote:        
remote:        up to date, audited 90 packages in 483ms
remote:        
remote:        11 packages are looking for funding
remote:          run `npm fund` for details
remote:        
remote:        found 0 vulnerabilities
remote:        
remote: -----> Build succeeded!
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing...
remote:        Done: 34.3M
remote: -----> Launching...
remote:        Released v6
remote:        https://takeoff1.herokuapp.com/ deployed to Heroku
remote: 
remote: This app is using the Heroku-20 stack, however a newer stack is available.
remote: To upgrade to Heroku-22, see:
remote: https://devcenter.heroku.com/articles/upgrading-to-the-latest-stack
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/takeoff1.git
   2cbf5c8..9f81b45  master -> master

package.json

   {
   "name": "server",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "type": "module",
   "proxy": "http://localhost:5001",
   "scripts": {
       "start": "nodemon index.js"
   },
   "keywords": [],
   "author": "",
   "license": "ISC",
   "dependencies": {
       "b": "^2.0.1",
       "body-parser": "^1.20.0",
       "cors": "^2.8.5",
       "dotenv": "^16.0.1",
       "express": "^4.18.1",
       "mongoose": "^6.4.0"
   },
   "engines": {
       "node": "15.x"
   }
}

I have double-checked that I have installed all the relevant imports I used, my app works fine when in the local host but not sure what is going on when deploying. Maybe I should triple check I have installed all the correct imports but not sure what else to do. Any suggestions or more details required?

all my used imports

import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';
import dotenv from "dotenv"

edit1 console log when heroku logs --tail was inputted sorry for leaving this out, I did check but I went to a dead end. The main error lines are the 2 end ones.

2022-06-30T20:51:51.971994+00:00 app[api]: Release v1 created by user tylergoyea@gmail.com
2022-06-30T20:51:51.971994+00:00 app[api]: Initial release by user tylergoyea@gmail.com
2022-06-30T20:51:52.870267+00:00 app[api]: Release v2 created by user tylergoyea@gmail.com
2022-06-30T20:51:52.870267+00:00 app[api]: Enable Logplex by user tylergoyea@gmail.com
2022-06-30T20:53:37.000000+00:00 app[api]: Build started by user tylergoyea@gmail.com
2022-06-30T20:53:57.000000+00:00 app[api]: Build succeeded
2022-06-30T20:53:57.158560+00:00 app[api]: Release v3 created by user tylergoyea@gmail.com
2022-06-30T20:53:57.158560+00:00 app[api]: Deploy 74759d6f by user tylergoyea@gmail.com
2022-06-30T20:53:57.175044+00:00 app[api]: Scaled to web@1:Free by user tylergoyea@gmail.com
2022-06-30T20:53:59.278057+00:00 heroku[web.1]: Starting process with command `npm run start`
2022-06-30T20:54:00.830436+00:00 app[web.1]: 
2022-06-30T20:54:00.830455+00:00 app[web.1]: > server@1.0.0 start
2022-06-30T20:54:00.830456+00:00 app[web.1]: > nodemon index.js
2022-06-30T20:54:00.830456+00:00 app[web.1]: 
2022-06-30T20:54:00.834673+00:00 app[web.1]: sh: 1: nodemon: not found
2022-06-30T20:54:00.967828+00:00 heroku[web.1]: Process exited with status 127
2022-06-30T20:54:01.024419+00:00 heroku[web.1]: State changed from starting to crashed
2022-06-30T20:54:01.033169+00:00 heroku[web.1]: State changed from crashed to starting
2022-06-30T20:54:02.864415+00:00 heroku[web.1]: Starting process with command `npm run start`
2022-06-30T20:54:03.977152+00:00 app[web.1]: 
2022-06-30T20:54:03.977164+00:00 app[web.1]: > server@1.0.0 start
2022-06-30T20:54:03.977164+00:00 app[web.1]: > nodemon index.js
2022-06-30T20:54:03.977164+00:00 app[web.1]: 
2022-06-30T20:54:03.984197+00:00 app[web.1]: sh: 1: nodemon: not found
2022-06-30T20:54:04.109627+00:00 heroku[web.1]: Process exited with status 127
2022-06-30T20:54:04.198798+00:00 heroku[web.1]: State changed from starting to crashed
2022-06-30T20:54:17.455064+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=takeoff1.herokuapp.com request_id=c456c72e-e3c2-4e5f-ab69-e160ab13aa17 fwd="176.205.231.50" dyno= connect= service= status=503 bytes= protocol=https
2022-06-30T20:54:17.945916+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=takeoff1.herokuapp.com request_id=8f43d3e6-a165-4934-86d5-6670768495bc fwd="176.205.231.50" dyno= connect= service= status=503 bytes= protocol=https

my index.js file:

import express from 'express';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import cors from 'cors';
import dotenv from "dotenv"
import postRoutes from './routes/posts.js';

const app = express();
dotenv.config()



app.use(bodyParser.json({ limit: "30mb", extended: true }))
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }))
app.use(cors());
app.use('/posts', postRoutes)
const PORT = process.env.PORT || 5001;

app.get('/', (req, res) => {
    res.send('Hello to Memories API')
});

mongoose.connect(process.env.CONNECTION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
    .then(() =>
        app.listen(PORT, () => { console.log(`Server running on port ${PORT}`) })
    ).catch((error) => console.log(error.message));
Tyler
  • 13
  • 3

0 Answers0