Home > front end >  heroku launches build and gets stuck
heroku launches build and gets stuck

Time:08-07

Log:

.\yoshi-realese> git push heroku master
Enumerating objects: 2449, done.
Counting objects: 100% (2449/2449), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2353/2353), done.
Writing objects: 100% (2449/2449), 4.63 MiB | 2.71 MiB/s, done.
Total 2449 (delta 275), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Node.js app detected
remote: -----> Build
remote:        Running build
remote:        > [email protected] build
remote:        > nodemon app.js
remote:        [nodemon] 2.0.19
remote:        [nodemon] to restart at any time, enter `rs`
remote:        [nodemon] watching path(s): *.*
remote:        [nodemon] watching extensions: js,mjs,json
remote:        [nodemon] starting `node app.js`
remote:        started yoshistore

After that nothing happens.

Here is my package.json:

{
  "name": "yoshi-v1",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "build": "nodemon app.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@handlebars/allow-prototype-access": "^1.0.5",
    "express": "^4.18.1",
    "express-handlebars": "^6.0.6",
    "handlebars": "^4.7.7",
    "mongoose": "^6.5.1",
    "nodemon": "^2.0.19"
  }
}

Screenshot

CodePudding user response:

Your build script tries to run your application:

"build": "nodemon app.js"

That's not what it is for. The build script is run once per deployment, when Heroku builds your application, to generate whatever artifacts your application needs.

That might involve compiling TypeScript to JavaScript, minifying code, tree shaking, or a whole bunch of other things. I'm not sure what yours should be, but you can try leaving it out entirely.

To run your application, Heroku will look at your Procfile. If no such file exists, it will run your start script as a web process. Try changing your package.json accordingly:

"scripts": {
  "start": "node app.js",
  "test": "echo \"Error: no test specified\" && exit 1"
}

Here I have changed build to start, and also swapped nodemon (which is a development tool that should not be used in production) with node.

  • Related