#Errors deploying to railway host

27 messages · Page 1 of 1 (latest)

willow nest
#

I'm deploying my nestjs API to an intended-to-be-production environment, but I'm facing a few issues and would like to know how to fix em and how to have an elegant CD pipeline.

I'm facing these errors during deploy, not sure if they're independent or if one causes the other:

  1. npm WARN config production Use --omit=dev instead.

node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module '/app/dist/main'
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v18.20.2
verbal canopy
willow nest
#

no dockerfile in my repo yet, but I can add if needed

verbal canopy
#

So what you're showing is errors with railway's cli to deploy ?

willow nest
#

just connected a "production" branch to railway, deploying using their web ui

verbal canopy
#

Can you send your railway configuration file ?

#

I feel like this isn't related to nest at all XD

willow nest
#

That's the problem: I have no conf file

#

I'm deploying this using website as much as I can, so my client would feel safer to manage the application

verbal canopy
#

Why would your client need to access railway ?

willow nest
#

Should I use some default DOckerfile or railway custom conf file?

willow nest
#

also they paid for another dev for creating some app during 2 years, guy vanished and gave them nothing, so they want to control stuff for now 😆

verbal canopy
#

ohh ok my bad, well if this way an issue with a dockerfile I could help, but sadly I dont know anything about railway

#

config files do not seem that difficult honestly, if you give code to your client idk why they would be scared of some json describing the deployment on railway x)

willow nest
#

You're right. I'll grab their example files and give it a shot

topaz rune
#

When you're not using own dockerfile, railway uses buildpacks, which is a universal docker toolkit that does some checks to determine what is going on:

  • if it sees package.json, then it's probably NodeJS project
  • if it sees yarn.lock it uses yarn to install dependencies
  • if it sees build in scripts section of package.json, it runs that as part of the process
    etc., that's just a sample, not exact steps.

Given that, it's difficult to tell what could go wrong - maybe it didn't find a start script, so it doesn't know what to run. Or it misdetected an entryfile.

Providing full build log should help in figuring out what went wrong.

willow nest
#

@topaz rune thanks! I'm trying to use a Dockerfile first, so here are my current dockerfile and my failed deploy log:

topaz rune
#

What if you add

RUN ls -lah ./dist

before your CMD and check the build logs?

#

Also, now that you have a dockerfile, you can run the build locally. Does it work on local?

willow nest
#

Trying to run on local. Got the same error, but couldn't find the returned value for the ls. I might try to use it in the CMD line

verbal canopy
#
docker run -it your-image /bin/sh # then run commands

#

you can also try to set a WORKDIR before copying files over on production stage

willow nest
#

Will try it and get back to you guys 🙂

#

my app is beign built on dist/src instead of dist.

#

Now I remember facing this same issue 2 years ago, that time I hosted the nest api in a shared host, controlled it with pm2, so I edited the package.json back then. Let me test it now