I'm trying to deploy a nestjs app to heroku but I get this error in the logs
2022-09-03T16:19:06.793730 00:00 app[web.1]: > [email protected] start:prod
2022-09-03T16:19:06.793731 00:00 app[web.1]: > node dist/main
2022-09-03T16:19:06.793731 00:00 app[web.1]:
2022-09-03T16:19:06.859243 00:00 app[web.1]: node:internal/modules/cjs/loader:959
2022-09-03T16:19:06.859244 00:00 app[web.1]: throw err;
2022-09-03T16:19:06.859245 00:00 app[web.1]: ^
2022-09-03T16:19:06.859245 00:00 app[web.1]:
2022-09-03T16:19:06.859245 00:00 app[web.1]: Error: Cannot find module '/app/dist/main'
2022-09-03T16:19:06.859246 00:00 app[web.1]: at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
2022-09-03T16:19:06.859247 00:00 app[web.1]: at Function.Module._load (node:internal/modules/cjs/loader:804:27)
2022-09-03T16:19:06.859247 00:00 app[web.1]: at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
2022-09-03T16:19:06.859247 00:00 app[web.1]: at node:internal/main/run_main_module:17:47 {
2022-09-03T16:19:06.859248 00:00 app[web.1]: code: 'MODULE_NOT_FOUND',
2022-09-03T16:19:06.859248 00:00 app[web.1]: requireStack: []
2022-09-03T16:19:06.859249 00:00 app[web.1]: }
I created a Procfile with npm run start:prod command, also tried moving @nestjs/cli
devDependency to dependencies but it doesn't work
Edit
Apparently Nest.js build the main.js in dist/src/
CodePudding user response:
Next js goes perfectly with vercel if you are not bounded with a single option to deploy
CodePudding user response:
The start:prod
command in the package.json
should be updated to read "start:prod": "node dsit/src/main"
due to how the project is built. Usually this means that there is a ts
file outside of src
that is being read as a part of the project, or some other import is happening to a file outside of the source root