Andrew D
Andrew D
RRailway
Created by Andrew D on 6/19/2023 in #✋|help
NestJS Monorepo: Cannot find module '/app/dist/apps/server/main' on server start
Hi all, Pretty new to Railway and Nest. I recently converted my isolated monorepo into a shared monorepo and am having problems deploying it. My basic directory structure looks like this after being built:
root
├── apps
│   ├── client
│   │   ├── app.vue
│   │   ├── apps
│   │   ├── public
│   │   └── tsconfig.json
│   └── server
│   ├── src
│   ├── test
│   └── tsconfig.app.json
├── dist
│   └── apps
│   └── server
├── node_modules
├── nest-cli.json
├── nuxt.config.ts
└── package.json
root
├── apps
│   ├── client
│   │   ├── app.vue
│   │   ├── apps
│   │   ├── public
│   │   └── tsconfig.json
│   └── server
│   ├── src
│   ├── test
│   └── tsconfig.app.json
├── dist
│   └── apps
│   └── server
├── node_modules
├── nest-cli.json
├── nuxt.config.ts
└── package.json
The build goes fine, but when I try and start my server, the deployment crashes with the following error:
> [email protected] server:start:prod
> node dist/apps/server/main
> node dist/apps/server/main
node:internal/modules/cjs/loader:988
node:internal/modules/cjs/loader:988
throw err;
throw err;
^
^
Error: Cannot find module '/app/dist/apps/server/main'
Error: Cannot find module '/app/dist/apps/server/main'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47 {
at node:internal/main/run_main_module:22:47 {
code: 'MODULE_NOT_FOUND',
code: 'MODULE_NOT_FOUND',
> [email protected] server:start:prod
> node dist/apps/server/main
> node dist/apps/server/main
node:internal/modules/cjs/loader:988
node:internal/modules/cjs/loader:988
throw err;
throw err;
^
^
Error: Cannot find module '/app/dist/apps/server/main'
Error: Cannot find module '/app/dist/apps/server/main'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Function.Module._load (node:internal/modules/cjs/loader:833:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:22:47 {
at node:internal/main/run_main_module:22:47 {
code: 'MODULE_NOT_FOUND',
code: 'MODULE_NOT_FOUND',
Seems like some path somewhere is getting malformed, and I'm new enough to both Railway and Nest to not be able to figure it out. I do not have a root directory configured in my app's settings, as locally, the server is able to be launched from the project root. Please let me know if you have any suggestions. Here is a link to the app's source code: https://github.com/andydeforest/name-that-player Thanks!
13 replies