Local Development
I am trying to run it locally, but I just don't know how. I've setted it up on my vscode, and when I type "railway run npm start" it goes as "node server.mjs", so I think it's running, but how do I check for my changes on it? And how to update it?
52 Replies
Project ID:
26373e9d-9ca4-47e7-b75b-8323a727f62f
You might find these helpful:
- Failing to deploy a NestJs api in Railways UI from a Turbo monorepo
- cli npm start listen on port 3000 - unable to connect
- Deployment failure
⚠️ experimental feature
26373e9d-9ca4-47e7-b75b-8323a727f62f
Railway run pushes your code to a container on Railway, it does not run your code locally. Running your code locally is as simple as running your start command. Same as any local development
edited title: no clickbait here, this isn't YouTube
If you want to test your nixpacks deploy for local development, you can download nixpacks
LOCAL DEVELOPMENT GONE WRONG!! (CONDUCTORS CALLED)
Sorry hahaha I tried to be as clear as possible
I mean, when I'm deploying to github, and make all changes, it works very well.. I just have to wait 3 minutes and then it shows up every changes
But when I run it locally, I don't know how to access to see what I've madfe
For example, I can't see the change on an input on my HTML
The project will begin building as soon as you push a commit. If it’s the build process you’re looking to skip, look into launching your project on your pc rather than pushing to Railway for every test
do you know how to run your project locally?
No, I don't haha
That's the problem
I just know how to type the railway run npm start
Ahh okay great. Head to your Railway service and go to the build logs. Scroll to the very top and you should see a start command. Send the table that the start command is in here
And then it starts, but how to use it locally I don't know
all that does is push your code to your service. It doesn’t start anything locally
Is it this?
No, go to your latest deployment
Here
if you had one manually defined it would be there, but you don’t
yup that’s it
Found it]
run that locally from a terminal created from your root directory and it should start up
you may have to install yarn. I’m not sure what the process for that is
I typed it
But nothing happened
Unfortunately I don’t know node so I can’t help further. Not sure what the process is to start a node server locally
google will be able to help you. Google “Starting a node server with yarn on windows”
Looks like it started to me, just without a callback function that would print a starting message, Look into the code and see what port it listens on, then just go to 127.0.0.1:<port>
In my code there is no port referenced to
Is it anywhere I can find the port?
That would be it?
Change that to
So when on railway it will use the port railway provides, and when running locally it will use 3000
Aright
To restart the server just hit ctrl+C and then click Yes, right?
Yes that would be the manual way
Okay, that worked, but now I'm getting errors with the consulting you helped me yesterday (with the fetch
Actually the problem is that it's not being able to keep it online
Looks like a database connection error to me?
Can you show me the bit of code that connects to the database?
Maybe that's not working bc I didn't even put anything about the server there?
Bc on the Railway is on the same enviroment, so that's not needed
That's the part that querys the database, can I see the part that connects to the database
There is none
Does database stuff work on railway?
Yes
Then there has to be code that connects to the database, get to searching
Oooh
Okay
When it's deployed, it doesn't needs any
That's why I didn't put it
Might be a package that will look for the environment variables itself
Okay either way, let's move on
Just run railway shell, then run yarn run start
Aright!
That worked out!
Thanks
Also, let me ask you, when I want to deplay it, I just have simply push it to git, that it'll be deployed?
Nope, you're good as long as you keep that shell open
I mean, to deploy it and use it not locally anymore
I just have to push it to git, right?
Yeah just push to git to deploy like normal, nothing changes there
Thank you!
Working locally now?
YESSS
Way easier and faster omg
hahaha
Awesome