NestJS app builds successfully but fails to start

Error: Cannot find module ‘/opt/render/project/src/dist/main.js’ at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) at Function.Module._load (internal/modules/cjs/loader.js:725:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 {
Oct 4 08:28:28 AM code: ‘MODULE_NOT_FOUND’,
Oct 4 08:28:28 AM requireStack:
Oct 4 08:28:28 AM }

@EasyCart We’re happy to take a look - can you DM me the name of the service?

Hi @EasyCart, @Jade_Paoletta, I am experiencing the exact same error:
Error: Cannot find module ‘/opt/render/project/src/dist/main’
Mar 18 04:44:53 PM at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
Mar 18 04:44:53 PM at Function.Module._load (internal/modules/cjs/loader.js:730:27)
Mar 18 04:44:53 PM at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
Mar 18 04:44:53 PM at internal/main/run_main_module.js:17:47 {
Mar 18 04:44:53 PM code: ‘MODULE_NOT_FOUND’,
Mar 18 04:44:53 PM requireStack:
Mar 18 04:44:53 PM }
Mar 18 04:44:53 PM npm ERR! code ELIFECYCLE
Mar 18 04:44:53 PM npm ERR! errno 1
Mar 18 04:44:53 PM npm ERR! smartpay-shop@0.0.1 start:prod: node dist/main
Mar 18 04:44:53 PM npm ERR! Exit status 1

Can you share the resolution/solution?

Hi,

This is a pretty old post, but your logs seem to show your code is looking for a file in the dist folder.

dist folders are often created with build scripts. Ensure your Build Command is set to install dependencies and build any files that are required.

Alan