Help with connecting my project made in html,css & js with nodejs has the backend....

Hello guys,so i am creating a fitness website and i wuant to host it online just for myseelf to test it out so i can have a prespective on how it would work if i was in the user side,i decied to use railway to host the backend ,and netlify for the frontend ,but i am having some problems to connect the backend unfortonely,i think i have connected the database but i dont am really sure if i did it right,can someone help ?
Solution:
you dont have a package.json and package-lock.json in that backend folder
Jump to solution
52 Replies
Percy
Percy2mo ago
Project ID: N/A
Brody
Brody2mo ago
what issues are you running into?
Richard Pinewood
Richard PinewoodOP2mo ago
N/A hiii
Richard Pinewood
Richard PinewoodOP2mo ago
so ,the thing is that this is happening
No description
Brody
Brody2mo ago
please share your repo
Richard Pinewood
Richard PinewoodOP2mo ago
sure
Richard Pinewood
Richard PinewoodOP2mo ago
GitHub
GitHub - RichardPinewood/InToLongevity: This is my first project
This is my first project. Contribute to RichardPinewood/InToLongevity development by creating an account on GitHub.
Richard Pinewood
Richard PinewoodOP2mo ago
i rooted in railway to /backend but still not working everything is in the same project the backend and the frontend
Solution
Brody
Brody2mo ago
you dont have a package.json and package-lock.json in that backend folder
Richard Pinewood
Richard PinewoodOP2mo ago
what do you mean ? do i need to add that ?
Brody
Brody2mo ago
yes those are node specific, without those nixpacks wont know what to do with this backend project
Richard Pinewood
Richard PinewoodOP2mo ago
they are in my project but not on github
No description
Richard Pinewood
Richard PinewoodOP2mo ago
do i need to add them to github ?
Brody
Brody2mo ago
you need them in the backend folder too and they need to be in github
Richard Pinewood
Richard PinewoodOP2mo ago
so how could i fix this ?
Brody
Brody2mo ago
create the files in the backend folder
Richard Pinewood
Richard PinewoodOP2mo ago
is there a command ? i mean they were installed automatically oh wait i did npm init y but wont it affect the project ?
Brody
Brody2mo ago
you need them in the backend folder
Richard Pinewood
Richard PinewoodOP2mo ago
because i will have two files.... wotj the same name
Brody
Brody2mo ago
^
Richard Pinewood
Richard PinewoodOP2mo ago
will it be fine ?
Brody
Brody2mo ago
considering its current broken, you cant make it worse, you need them, there is no two ways about that
Richard Pinewood
Richard PinewoodOP2mo ago
hmmmm what is going on now ? Error: Cannot find module 'express' Require stack: - /app/server.js at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15) at Module._load (node:internal/modules/cjs/loader:981:27) at Module.require (node:internal/modules/cjs/loader:1231:19) at require (node:internal/modules/helpers:177:18) at Object.<anonymous> (/app/server.js:1:17) at Module._compile (node:internal/modules/cjs/loader:1364:14) at Module._extensions..js (node:internal/modules/cjs/loader:1422:10) at Module.load (node:internal/modules/cjs/loader:1203:32) at Module._load (node:internal/modules/cjs/loader:1019:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) { code: 'MODULE_NOT_FOUND', requireStack: [ '/app/server.js' ] } Node.js v18.20.2 it is appearing in railway logs
Brody
Brody2mo ago
you need to have all your needed dependences in your package.json
Richard Pinewood
Richard PinewoodOP2mo ago
what dependencies ?
Brody
Brody2mo ago
well an example would be express for one
Richard Pinewood
Richard PinewoodOP2mo ago
if i install express will railway know ? or even github form my machine ?
Brody
Brody2mo ago
it will install it because its listed in your package.json
Richard Pinewood
Richard PinewoodOP2mo ago
did it finished ???
No description
Richard Pinewood
Richard PinewoodOP2mo ago
finnally i installed all depencies @Brody
Brody
Brody2mo ago
yes it says active, now you need to generate a domain
Richard Pinewood
Richard PinewoodOP2mo ago
for what ? in railway ? you mean in the frontend ?
Richard Pinewood
Richard PinewoodOP2mo ago
will the domain serve for netlify ?
Brody
Brody2mo ago
this will be the domain for your backend
Richard Pinewood
Richard PinewoodOP2mo ago
i see a domain in Private Networking
Brody
Brody2mo ago
you need to generate a public domain
Richard Pinewood
Richard PinewoodOP2mo ago
i see can i choose a domain i like ?
Brody
Brody2mo ago
yes
Richard Pinewood
Richard PinewoodOP2mo ago
doneee were should i implement that domain in netlify ?
Brody
Brody2mo ago
your frontend code needs to call the domain, it would not have anything to do with netlify specifically
Richard Pinewood
Richard PinewoodOP2mo ago
but i wont need later to do node server.js ? if imagine i use netlify
Brody
Brody2mo ago
railway is running the server, not netlify
Richard Pinewood
Richard PinewoodOP2mo ago
i knoww but late one i wont need to do the command right ? when i finish to integrate the frontend and the backend online
Brody
Brody2mo ago
uh sure, i dont really understand the question / your english, sorry
Richard Pinewood
Richard PinewoodOP2mo ago
imagine if i deploy the backend in railway,i wont need to use the terminal later ?
Brody
Brody2mo ago
i guess
Richard Pinewood
Richard PinewoodOP2mo ago
@Brody do you know about vercel ?
No description
Richard Pinewood
Richard PinewoodOP2mo ago
i am trying to host my frontend in here but it is appearing me this error 404
Brody
Brody2mo ago
we can't provide support for platforms that arent railway
Richard Pinewood
Richard PinewoodOP2mo ago
boomer
Brody
Brody2mo ago
i don't see how that is productive to the conversation, going to close this thread out.
Want results from more Discord servers?
Add your server