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
Percy
Percy2y ago
Project ID: 26373e9d-9ca4-47e7-b75b-8323a727f62f
KChammas
KChammasOP2y ago
26373e9d-9ca4-47e7-b75b-8323a727f62f
Adam
Adam2y ago
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
angelo
angelo2y ago
edited title: no clickbait here, this isn't YouTube
Adam
Adam2y ago
If you want to test your nixpacks deploy for local development, you can download nixpacks LOCAL DEVELOPMENT GONE WRONG!! (CONDUCTORS CALLED)
KChammas
KChammasOP2y ago
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
Adam
Adam2y ago
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?
KChammas
KChammasOP2y ago
No, I don't haha That's the problem I just know how to type the railway run npm start
Adam
Adam2y ago
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
KChammas
KChammasOP2y ago
And then it starts, but how to use it locally I don't know
Adam
Adam2y ago
all that does is push your code to your service. It doesn’t start anything locally
KChammas
KChammasOP2y ago
KChammas
KChammasOP2y ago
Is it this?
Adam
Adam2y ago
No, go to your latest deployment
KChammas
KChammasOP2y ago
KChammas
KChammasOP2y ago
Here
Adam
Adam2y ago
if you had one manually defined it would be there, but you don’t yup that’s it
KChammas
KChammasOP2y ago
Found it]
Adam
Adam2y ago
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
KChammas
KChammasOP2y ago
KChammas
KChammasOP2y ago
I typed it But nothing happened
Adam
Adam2y ago
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”
Brody
Brody2y ago
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>
KChammas
KChammasOP2y ago
In my code there is no port referenced to Is it anywhere I can find the port?
KChammas
KChammasOP2y ago
KChammas
KChammasOP2y ago
That would be it?
Brody
Brody2y ago
Change that to
process.env.PORT || 3000
process.env.PORT || 3000
So when on railway it will use the port railway provides, and when running locally it will use 3000
KChammas
KChammasOP2y ago
Aright To restart the server just hit ctrl+C and then click Yes, right?
Brody
Brody2y ago
Yes that would be the manual way
KChammas
KChammasOP2y ago
Okay, that worked, but now I'm getting errors with the consulting you helped me yesterday (with the fetch
KChammas
KChammasOP2y ago
KChammas
KChammasOP2y ago
KChammas
KChammasOP2y ago
Actually the problem is that it's not being able to keep it online
Brody
Brody2y ago
Looks like a database connection error to me? Can you show me the bit of code that connects to the database?
KChammas
KChammasOP2y ago
KChammas
KChammasOP2y ago
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
Brody
Brody2y ago
That's the part that querys the database, can I see the part that connects to the database
KChammas
KChammasOP2y ago
There is none
Brody
Brody2y ago
Does database stuff work on railway?
KChammas
KChammasOP2y ago
Yes
Brody
Brody2y ago
Then there has to be code that connects to the database, get to searching
KChammas
KChammasOP2y ago
Oooh Okay When it's deployed, it doesn't needs any That's why I didn't put it
Brody
Brody2y ago
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
KChammas
KChammasOP2y ago
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?
Brody
Brody2y ago
Nope, you're good as long as you keep that shell open
KChammas
KChammasOP2y ago
I mean, to deploy it and use it not locally anymore I just have to push it to git, right?
Brody
Brody2y ago
Yeah just push to git to deploy like normal, nothing changes there
KChammas
KChammasOP2y ago
Thank you!
Brody
Brody2y ago
Working locally now?
KChammas
KChammasOP2y ago
YESSS Way easier and faster omg hahaha
Brody
Brody2y ago
Awesome
Want results from more Discord servers?
Add your server