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