Search code examples
githubherokunestjs

Application Error from heroku for NestJS app


There isn’t an error showed in the log when deploying my NestJS app to heroku but actually it doesn’t works with a messages saying « Application Error ...» and the blur thing is that, the app was working perfectly there connected from GitHub. Then I deleted that app and git clone it for a very deep change but I didn’t touched the heroku configurations that I made for the first deployment. So I don’t know what exactly is the issue. App is running perfectly locally on process.env.PORT || 8080


Solution

  • Finally, I found my issue solution.

    So if bro you have the same issue, make sure all the Heroku's configurations are perfectly done so that at that time, no issue will show in the log but your NestTs app isn't working with Application Error showing, just run the following command: nest build or npm run build.

    When it's done, open the folder automatically generated named dist on top of your other folders in the root directory of your NestTs app, in that folder (dist) are listed all the files and folders you have in your root directory and some of those files has extension js, then try to find a file named main.js, and write down its location like (dist/src/main.js or dist/main.js) and put that location in your package.json under script in start:prod value.

        ...
    "scripts": {
    "start:prod": "node dist/main.js", /*here where you should add the
    loction of main.js don't forget to add the extension .js*/
    },
    ...