R
Railway11mo ago
zara

I am unable to deploy my project as the build log only says Nixpacks was unable to generate a build.

My project has it's variables as well so I'm not sure what I'm missing. It says to add nixpacks to homebrew in the documentation however, I don't see how this will help as its on my local machine and not related to GitHub transferring the project to railway. Please advice. Thank you.
111 Replies
Percy
Percy11mo ago
Project ID: 55e5911d-8c6d-4e69-8044-6387da48f2b8
zara
zaraOP11mo ago
55e5911d-8c6d-4e69-8044-6387da48f2b8 Ok I'm unable to get this bookmarklet thing working I did as the directions stated drag to the bookmarks bar but it doesn't do anything I can't connect the logs to the link you provided
Brody
Brody11mo ago
please follow the 3 instructions on the page
zara
zaraOP11mo ago
Ok I think it worked this timw please check
Brody
Brody11mo ago
check what? send me the log file that the bookmarklet provided you
Brody
Brody11mo ago
can you share your repo?
zara
zaraOP11mo ago
yes
zara
zaraOP11mo ago
GitHub
GitHub - mehjwazir/journal-notes
Contribute to mehjwazir/journal-notes development by creating an account on GitHub.
Brody
Brody11mo ago
okay theres a few things we have to do to get this running on railway
zara
zaraOP11mo ago
ok lmk
Brody
Brody11mo ago
your backend's current start script uses nodemon, we dont want to use nodmon on railway, please fix that
zara
zaraOP11mo ago
what should I change it to?
Brody
Brody11mo ago
something with ts-node im not sure as im not a javascript dev, but i know that you dont want to use nodemon
zara
zaraOP11mo ago
ok give me a few minutes to figure this out
Brody
Brody11mo ago
sounds good
root
root11mo ago
preferably run tsc in the build script and then normal node for the run
zara
zaraOP11mo ago
something like this "scripts": { "build": "tsc -p backend", "start": "node backend/dist/server.js", "lint": "eslint . --ext .ts", "test": "echo "Error: no test specified" && exit 1" },
root
root11mo ago
looks about right
zara
zaraOP11mo ago
ok let me make a commit and see if this works
Brody
Brody11mo ago
that doesn't look right to me
zara
zaraOP11mo ago
yeah it didn't work
Brody
Brody11mo ago
for transparency there's more than just fixing the scripts before you get the deployment working, don't worry about that failing, it will continue to fail for a while but about the scripts, you are specifying the folder name within them, your package.json is already in the backend folder so you don't need to specify the directory
zara
zaraOP11mo ago
I thought so lol i asked chat gpt lol would it be this "start": "node dist/index.js"
Brody
Brody11mo ago
that definitely looks better, but instead of both of us guessing, you would need to run the build locally first (and for that you need to have a working build script)
zara
zaraOP11mo ago
trying a few things but will update soon thanks Ok so we tried a couple of things in tsconfig.json and changed the scripts but it still is not able to deploy. Also the logs are not very helpful. Aside from the nixpacks message there is no other information as to why the build is failing. this is what I have currently { "name": "backend", "version": "1.0.0", "description": "", "main": "server.js", "scripts": { "build": "npx tsc", "start": "node dist/server.js", "lint": "eslint . --ext .ts", "test": "echo "Error: no test specified" && exit 1" }, it should have worked please ask a tech lead in your department for react/typescript projects what start script to use
Brody
Brody11mo ago
please do not worry about the build logs on railway yet, that is very much expected at this point locally when you run "npm run build" do you end up with a "dist/server.js" file?
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
looks good, are these changed pushed to github so I can take a look?
zara
zaraOP11mo ago
yes they are
Brody
Brody11mo ago
okay backend looks good, let's move on to the frontend
zara
zaraOP11mo ago
ok
Brody
Brody11mo ago
https://github.com/brody192/create-react-app-starter/tree/main copy the nixpacks.toml and Caddyfile from this repo into your frontend folder and after that, can you show me a screenshot of your railway project
zara
zaraOP11mo ago
No description
zara
zaraOP11mo ago
I added the nixpacks.toml and Caddyfile to the frontend and made a commit this is the log after which failed
Brody
Brody11mo ago
remember what I said, this is very much expected at this point I will let you know when I think it will work please send a screenshot of your railway project
zara
zaraOP11mo ago
Can you specify what to screen shot as there are different screen on railway for the project
Brody
Brody11mo ago
a screenshot of the entire web page while you have it open to your railway project
zara
zaraOP11mo ago
No description
No description
zara
zaraOP11mo ago
Are these what you're asking for?
Brody
Brody11mo ago
sorry i havent been able to be as responsive as id like, been making dinner you have an isolated monorepo, and within that you have two apps, a backend and a frontend app. this means you need two railway services. lets start with deploying the backend, that service you already have will be the backend, change its name to something like Journal Notes - Backend
zara
zaraOP11mo ago
Ok I changed the name to Journal Notes - Backend for this one how do we go about configuring the frontend to a new project
Brody
Brody11mo ago
one step at a time, we will get there in the end does your backend need a database or any api keys set? from a super quick glance, looks like it needs a mongo database?
zara
zaraOP11mo ago
yes it has a database set up with mongo
Brody
Brody11mo ago
i dont see mongo in the screenshot?
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
i mean i still dont see mongo lol, but also you named the project, not the service name the project "Journal Notes" name the service "Journal Notes - Backend"
zara
zaraOP11mo ago
oh yes I forgot to send that screen shot i changed it in Service
Brody
Brody11mo ago
do you host mongo on atlas or something? where is your database hosted?
zara
zaraOP11mo ago
lol yes in mongo atlast
Brody
Brody11mo ago
okay gotcha, new screenshot please? please do this
zara
zaraOP11mo ago
No description
zara
zaraOP11mo ago
i sent the wrong one i have a lot of screen shots
Brody
Brody11mo ago
your project name still has backend in it not important to the deployment, but its confusing lol
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
perfect okay go into its service settings and set the root directory to /backend
zara
zaraOP11mo ago
ok its updated and we're in the green
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
you want to have a domain, so to the service settings and generate one
zara
zaraOP11mo ago
yeah I originally had journal-notes with railway I can just leave that like this journal-notes.up.railway.app
Brody
Brody11mo ago
im not sure what you mean by that? from your screenshot i can tell you that the service does not have a domain
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
okay now theres a domain! what happens when you open that in the browser?
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
looks good, totally normal message to see
zara
zaraOP11mo ago
yup ok lmk what we shall move on to next
Brody
Brody11mo ago
within the same project, deploy your github repo again and screenshot when thats done please
zara
zaraOP11mo ago
No description
zara
zaraOP11mo ago
should i change it to /frontend and also the service ok, I added them and it is in the green the only confusing thing is the domain and getting it to tie together so I'll wait for your advice. Thank you!
Brody
Brody11mo ago
yeah name it Journal Notes - Frontend the domains won't tie together, they will be separate domains, but I don't see this as a total issue, it will just require some simple code changes change the backend service domain to something like journal-notes-backend.up.railway.app
zara
zaraOP11mo ago
Ok I changed the backend one and what shall I do the frontend
Brody
Brody11mo ago
that one can have a domain named journal-notes.up.railway.app
zara
zaraOP11mo ago
Ok done
Brody
Brody11mo ago
screenshot please
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
looking good on the frontend service, add a service variable REACT_APP_BACKEND_URL=${{Journal Notes - Backend.RAILWAY_PUBLIC_DOMAIN}} after you add that, click it's eye icon to make sure it renders properly
zara
zaraOP11mo ago
Ok I added it and checked the eye.
Brody
Brody11mo ago
sorry my bad, it should be REACT_APP_BACKEND_URL=https://${{Journal Notes - Backend.RAILWAY_PUBLIC_DOMAIN}} i forgot the https:// lol
zara
zaraOP11mo ago
changed it currently building ok done
Brody
Brody11mo ago
its not going to do anything, it was only needed for a future code change
zara
zaraOP11mo ago
i see well either way it has updated
Brody
Brody11mo ago
https://github.com/mehjwazir/journal-notes/blob/main/frontend/src/network/notes_api.ts#L37 instead of making a fetch request to /api/users/signup you instead need to make a fetch request to process.env.REACT_APP_BACKEND_URL + "/api/users/signup" and you will need to make this kind of change everywhere in your code that you do a fetch request to the backend
zara
zaraOP11mo ago
That is making a lot of changes hopefully it will be ok lol. I changed the fetch requests and added to every path process.env.REACT_APP_BACKEND_URL + do I need to add anything to the .env file in backend ?
Brody
Brody11mo ago
nope, but let me know when those changes are on github
zara
zaraOP11mo ago
ok shall i run locally to see if its working with this though? it works ok let me make a commit actually its not working when I login 404
Brody
Brody11mo ago
its not going to work locally yet, lets tackle the railway side of things first
zara
zaraOP11mo ago
I see ok ok i made the changes should be on github
Brody
Brody11mo ago
okay did the railway deploy of the frontend finish?
zara
zaraOP11mo ago
yes What shall we do next?
Brody
Brody11mo ago
does it work?
zara
zaraOP11mo ago
the link does work but it doesn't seem to connecting to the backend properly with sign up or login
Brody
Brody11mo ago
can you send me a link so i can reproduce that?
zara
zaraOP11mo ago
SyntaxError: Unexpected end of JSON input
Brody
Brody11mo ago
can you show me the raw editor window for your frontend variables?
zara
zaraOP11mo ago
there was a typo let me update and see if it works one moment
Brody
Brody11mo ago
can you show me it anyway?
zara
zaraOP11mo ago
No description
zara
zaraOP11mo ago
yeah it didn't work when I updated
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
show me what the eye icon shows?
zara
zaraOP11mo ago
No description
Brody
Brody11mo ago
i no longer get that error, now i get a cors error you use express right?
zara
zaraOP11mo ago
yeah
Brody
Brody11mo ago
then youll need to use the cors middleware in your backend, have a look at their docs for that https://expressjs.com/en/resources/middleware/cors.html let me know when thats implemented in your backend!
zara
zaraOP11mo ago
Ok I'll take a look at it and get back to you Not sure how late we can go on. I also didn't have dinner yet. Can I get back to you tomorrow on the same ticket?
Brody
Brody11mo ago
of course id be around, but feel free to ping me
zara
zaraOP11mo ago
Great! Thank you so much for all the help today in case I don't get back to you tonight.
Brody
Brody11mo ago
happy to help!
zara
zaraOP11mo ago
wow I first messaged you at 3ish long day hopefully it works soon k buh bye
Want results from more Discord servers?
Add your server