Search code examples
node.jsheroku

How to specify a file to heroku execute first


Im using node,js and getting this LOG from heroku, i think it is a missing file that heroku didn't find. but in the Json file i put the main file to my index.js but still not working and do not see any post about it

Build succeeded!
 !     This app may not specify any way to start a node process
       https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...

PACKAGE.JSON_IMAGE


Solution

  • The log you showed is fine.
    Procfile is necessary when no proc is defined. The "default" for a nodejs buildpack is npm start.
    In your package.json you defined under scripts what start does.

    In Python projects you don't have something similar to npm start. So there you would have to create a Procfile with e.g. the content worker: python myproject.py


    edit, package.json was added

    Here is a project that is compatible with Heroku. It's on the heroku branch not master/main: https://github.com/d-zone-org/d-zone/tree/heroku

    This is there scripts section in package.json

      "scripts": {
        "test": "echo \"Error: no test specified\" && exit 1",
        "build": "browserify web/main.js -t brfs -g uglifyify -o web/static/bundle.js",
        "watch": "watchify web/main.js -t brfs -d -o web/static/bundle.js -v",
        "start": "node index.js"
      },
    

    In your picture you don't have a start script defined.