R
Railway10mo 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
Percy10mo ago
Project ID: 55e5911d-8c6d-4e69-8044-6387da48f2b8
zara
zara10mo 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
Brody10mo ago
please follow the 3 instructions on the page
zara
zara10mo ago
Ok I think it worked this timw please check
Brody
Brody10mo ago
check what? send me the log file that the bookmarklet provided you
Brody
Brody10mo ago
can you share your repo?
zara
zara10mo ago
yes
zara
zara10mo ago
GitHub
GitHub - mehjwazir/journal-notes
Contribute to mehjwazir/journal-notes development by creating an account on GitHub.
Brody
Brody10mo ago
okay theres a few things we have to do to get this running on railway
zara
zara10mo ago
ok lmk
Brody
Brody10mo ago
your backend's current start script uses nodemon, we dont want to use nodmon on railway, please fix that
zara
zara10mo ago
what should I change it to?
Brody
Brody10mo 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
zara10mo ago
ok give me a few minutes to figure this out
Brody
Brody10mo ago
sounds good
root
root10mo ago
preferably run tsc in the build script and then normal node for the run
zara
zara10mo 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
root10mo ago
looks about right
zara
zara10mo ago
ok let me make a commit and see if this works
Brody
Brody10mo ago
that doesn't look right to me
zara
zara10mo ago
yeah it didn't work
Brody
Brody10mo 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
zara10mo ago
I thought so lol i asked chat gpt lol would it be this "start": "node dist/index.js"
Brody
Brody10mo 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
zara10mo 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
Brody10mo 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
zara10mo ago
No description
Brody
Brody10mo ago
looks good, are these changed pushed to github so I can take a look?
zara
zara10mo ago
yes they are
Brody
Brody10mo ago
okay backend looks good, let's move on to the frontend
zara
zara10mo ago
ok
Brody
Brody10mo 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
zara10mo ago
No description
zara
zara10mo ago
I added the nixpacks.toml and Caddyfile to the frontend and made a commit this is the log after which failed
Brody
Brody10mo 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
zara10mo ago
Can you specify what to screen shot as there are different screen on railway for the project
Brody
Brody10mo ago
a screenshot of the entire web page while you have it open to your railway project
zara
zara10mo ago
No description
No description
zara
zara10mo ago
Are these what you're asking for?
Brody
Brody10mo 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
zara10mo 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
Brody10mo 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
zara10mo ago
yes it has a database set up with mongo
Brody
Brody10mo ago
i dont see mongo in the screenshot?
zara
zara10mo ago
No description
Brody
Brody10mo 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
zara10mo ago
oh yes I forgot to send that screen shot i changed it in Service
Brody
Brody10mo ago
do you host mongo on atlas or something? where is your database hosted?
zara
zara10mo ago
lol yes in mongo atlast
Brody
Brody10mo ago
okay gotcha, new screenshot please? please do this
zara
zara10mo ago
No description
zara
zara10mo ago
i sent the wrong one i have a lot of screen shots
Brody
Brody10mo ago
your project name still has backend in it not important to the deployment, but its confusing lol
zara
zara10mo ago
No description
Brody
Brody10mo ago
perfect okay go into its service settings and set the root directory to /backend
zara
zara10mo ago
ok its updated and we're in the green
zara
zara10mo ago
No description
Brody
Brody10mo ago
you want to have a domain, so to the service settings and generate one
zara
zara10mo ago
yeah I originally had journal-notes with railway I can just leave that like this journal-notes.up.railway.app
Brody
Brody10mo 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
zara10mo ago
No description
Brody
Brody10mo ago
okay now theres a domain! what happens when you open that in the browser?
zara
zara10mo ago
No description
Brody
Brody10mo ago
looks good, totally normal message to see
zara
zara10mo ago
yup ok lmk what we shall move on to next
Brody
Brody10mo ago
within the same project, deploy your github repo again and screenshot when thats done please
zara
zara10mo ago
No description
zara
zara10mo 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
Brody10mo 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
zara10mo ago
Ok I changed the backend one and what shall I do the frontend
Brody
Brody10mo ago
that one can have a domain named journal-notes.up.railway.app
zara
zara10mo ago
Ok done
Brody
Brody10mo ago
screenshot please
zara
zara10mo ago
No description
Brody
Brody10mo 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
zara10mo ago
Ok I added it and checked the eye.
Brody
Brody10mo ago
sorry my bad, it should be REACT_APP_BACKEND_URL=https://${{Journal Notes - Backend.RAILWAY_PUBLIC_DOMAIN}} i forgot the https:// lol
zara
zara10mo ago
changed it currently building ok done
Brody
Brody10mo ago
its not going to do anything, it was only needed for a future code change
zara
zara10mo ago
i see well either way it has updated
Brody
Brody10mo 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
zara10mo 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
Brody10mo ago
nope, but let me know when those changes are on github
zara
zara10mo 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
Brody10mo ago
its not going to work locally yet, lets tackle the railway side of things first
zara
zara10mo ago
I see ok ok i made the changes should be on github
Brody
Brody10mo ago
okay did the railway deploy of the frontend finish?
zara
zara10mo ago
yes What shall we do next?
Brody
Brody10mo ago
does it work?
zara
zara10mo ago
the link does work but it doesn't seem to connecting to the backend properly with sign up or login
Brody
Brody10mo ago
can you send me a link so i can reproduce that?
zara
zara10mo ago
SyntaxError: Unexpected end of JSON input
Brody
Brody10mo ago
can you show me the raw editor window for your frontend variables?
zara
zara10mo ago
there was a typo let me update and see if it works one moment
Brody
Brody10mo ago
can you show me it anyway?
zara
zara10mo ago
No description
zara
zara10mo ago
yeah it didn't work when I updated
zara
zara10mo ago
No description
Brody
Brody10mo ago
show me what the eye icon shows?
zara
zara10mo ago
No description
Brody
Brody10mo ago
i no longer get that error, now i get a cors error you use express right?
zara
zara10mo ago
yeah
Brody
Brody10mo 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
zara10mo 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
Brody10mo ago
of course id be around, but feel free to ping me
zara
zara10mo ago
Great! Thank you so much for all the help today in case I don't get back to you tonight.
Brody
Brody10mo ago
happy to help!
zara
zara10mo 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