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:
The build goes fine, but when I try and start my server, the deployment crashes with the following error:
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!GitHub
GitHub - andydeforest/name-that-player: Server and client code for ...
Server and client code for a historical baseball guessing game - GitHub - andydeforest/name-that-player: Server and client code for a historical baseball guessing game
7 Replies
Project ID:
2bc44233-73d7-49db-97bb-7fd40351d89b
2bc44233-73d7-49db-97bb-7fd40351d89b
1. leave root directory empty
2. set build command to
npm run server:build
3. set start command to npm run server:start:prod
4. make sure you have the postgres variable references setup correctly
https://docs.railway.app/develop/variables#reference-variables
5. in your package.json change the server:start:prod
script to node dist/main.js
i think thats everything, if you run into any issues let me know!@brody192 Thank you for the response! Can you elaborate on #1 a little?
in the railway service settings, you should not be specifying a root directory, aka leave it empty
Oh gotcha! Tyvm, will give that a shot 🙂
railway.json:
package.json scripts:
But still unfortunately not finding the correct path:
Ahh, there we go! Looks like changing the start script to
"server:start:prod": "node dist/apps/server/main.js"
did the trick! Thank you for the help!awesome, glad we could solve this