Unable to build client side of CRUD app.
rdelva
TRIALOP

2 years ago

Good Evening, I hope everyone is well. I'm new to deploying to railway and fullstack and I'm stuck on deploying a CRUD app.
This is what I have so far, any help would be greatly appreciated. My project id is : 66f997fc-fd5a-467c-a115-93b1badaf202

App is divided into two parts the api and client.

**API ** : https://fullstackapp-production-36a6.up.railway.app/

Client : should be https://client-production-cf5a.up.railway.app

Added the client (The log for the client is attached ) . When I deployed it I got an error that says

  • UndefinedVar: Usage of undefined variable '$NIXPACKS_PATH' (line 18)
    LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 18)

I have no idea what this means and I'm a bit new at this so I apologize if I ask alot of questions. Thank you very much for your help and your patience.

58 Replies

2 years ago

Hey, the error you mentioned is just a warning and won't effect anything, I took a look at your build logs and it seems your error is:

#10 2.141 npm ERR!
code EUSAGE
#10 2.145 npm ERR!
#10 2.145 npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
#10 2.145 npm ERR!
#10 2.145 npm ERR! Invalid: lock file's typescript@5.5.2 does not satisfy typescript@4.9.5
#10 2.145 npm ERR!
#10 2.145 npm ERR! Clean install a project

Essentially, you just need to resynchronize your lockfile, which you can do by running npm install and then committing again


rdelva
TRIALOP

2 years ago

@Fragly okay.. I'll do that.. thank you


rdelva
TRIALOP

2 years ago

@Fragly I just need to reinsall react again on the client side?


2 years ago

You just need to run npm install on your side to resync the the package-lock file

Also if you're using react app then I'd recommend you copy the Caddyfile and nixpacks.toml from this repo by Brody into your repo:

( or if you're using vite then just do the same with )

This just ensures you're running it properly on Railway


rdelva
TRIALOP

2 years ago

sorry to bother you.. should i run the npm install at the root or in the client folder?


rdelva
TRIALOP

2 years ago

@Fragly Thank you for assisting me, with the project. I removed package-lock.json and it was able to deploy. But when I typed npm install to create a new package-lock.json and pushed a new version it failed. Also should I create a new thread


2 years ago

We can keep going in this thread, can you share your build logs?


rdelva
TRIALOP

2 years ago

sure..give me one moment


rdelva
TRIALOP

2 years ago

sorry to bother you on this


2 years ago

no worries!


rdelva
TRIALOP

2 years ago


2 years ago

It's still not synchronized D: this time it's even more unsynchronized cause there's a whole dependency missing too now


rdelva
TRIALOP

2 years ago

awww nooo


rdelva
TRIALOP

2 years ago

how do you see it


2 years ago

If you did run npm install and then didn't change anything in your package.json afterwards which may have lead to it losing synchronization again then I'm wondering if you're not perhaps gitignoring the lockfile and github is now just storing a super duper outdated lockfile 🤔


2 years ago

in your build logs:

#11 2.359 npm ERR!
code EUSAGE
#11 2.365 npm ERR!
#11 2.365 npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
#11 2.365 npm ERR!
#11 2.365 npm ERR! Missing: fsevents@2.3.3 from lock file
#11 2.365 npm ERR! Invalid: lock file's typescript@5.5.2 does not satisfy typescript@4.9.5
#11 2.365 npm ERR!
#11 2.365 npm ERR! Clean install a project
#11 2.365 npm ERR!
#11 2.365 npm ERR! Usage:
#11 2.365 npm ERR! npm ci
#11 2.365 npm ERR!

rdelva
TRIALOP

2 years ago

i do have a .gitignore in my client folder


2 years ago

is it set to ignore the lockfile?


rdelva
TRIALOP

2 years ago


2 years ago

oh cool, this certainly makes it easier


rdelva
TRIALOP

2 years ago

🙂


rdelva
TRIALOP

2 years ago

the lockfile isn't in there though.. just other stuff.. but i'm not sure that would cause th eissue


2 years ago

yea, you're not gitignoring it, I'm pretty confused now 🤣


rdelva
TRIALOP

2 years ago

no worries.


rdelva
TRIALOP

2 years ago

I did use typescript on the api side


rdelva
TRIALOP

2 years ago

but not in the client side


rdelva
TRIALOP

2 years ago

and both folders both have there own package-lock.json file


rdelva
TRIALOP

2 years ago

wait.. I looked at my api thing.. no I didn't 😦


2 years ago

While I'm looking through your project, I'm noticing a lot of things that is very bad to do in production:

  1. in the API side, you're running the API using nodemon, it's very very bad to do that in production, run your app using node instead

  2. in the API side, you're running npm i on build, you don't want to do that. Railway will install dependencies for you

  3. in the API side, you're pushing your SQLite database to github, this is bad because it means once deployed, it won't persist through redeployments and it's a security vulnerability. This db includes passwords and your github is public 😬 you should consider getting rid of it ASAP. For future, you'd want to load your SQLite database into a volume using Filebrowser and then use it through there

  4. your Caddyfile and nixpacks.toml was supposed to be thrown into the client side of your app, not in the root

as for the current problem you're facing, it's definitely an issue with desynchronization between your package json and package lock json.. I'd recommend you try running npm install --package-lock-only again on the client side. if it still doesn't work after that then I'm out of ideas..

Useful resources:

  • -


rdelva
TRIALOP

2 years ago

thank you. I'll defintely making adjustments. Unfortunately this was from a teamtreehouse final project and the final part of it was to learn how to deploy it on railway


2 years ago

No problem!! What node version are you using locally?


rdelva
TRIALOP

2 years ago

i'm not sure.. its been a minute since I last checked


rdelva
TRIALOP

2 years ago

one moment


rdelva
TRIALOP

2 years ago

Node.js v16.13.2.


2 years ago

Version mismatch could be a probem.. Railway runs Node 18 by default, you can change the version railway uses by setting the engine in your package json files or just upgrade to node 18 on your side before regenerating the lockfile


rdelva
TRIALOP

2 years ago

nods


rdelva
TRIALOP

2 years ago

k.. I'll do that..


2 years ago

Good luck :D


rdelva
TRIALOP

2 years ago

thank you again… if I'm stuck again..am I better off rebuilding and recreating everything again


2 years ago

I'm sure the app itself is fine, the issues I mentioned above are easy fixes luckily.. well except the public database one - that's practically unfixable, well you can fix it but it's gonna be hard to remove the damage since the creds will be in the github repo and you'll need to remove each commit containing it


rdelva
TRIALOP

2 years ago

the public database is fake.. they did it for learning purposes. But you do have a valid point that this isn't the best way to do it.


2 years ago

ohh okay, I had a feeling that was the case


rdelva
TRIALOP

2 years ago

Deployment was successful but the logged changed 😦


rdelva
TRIALOP

2 years ago

should I create a different thread for this?


rdelva
TRIALOP

2 years ago


2 years ago

I think you might've made your start command a build command on your service settings, just need to remove that


rdelva
TRIALOP

2 years ago

okie..thank you


rdelva
TRIALOP

2 years ago

VICTORY!!!!!


rdelva
TRIALOP

2 years ago

well almost something



2 years ago

Awesome!!! Happy to hear


rdelva
TRIALOP

2 years ago

thank you so much.. your patience with me.. .


2 years ago

of course <:SmileFluent:865334941150871592> it was no trouble at all


rdelva
TRIALOP

2 years ago

just one more thing.. int he future..whats the best way to prevent the desyncronization of the package-lock.json


2 years ago

In this case it likely was the version mismatch that caused the problems, prevention for that would just be to specify your node version in packagejson at all times

Although to prevent that desynchronization, just don't edit dependencies or dependency versions straight from package json - use commands instead, or if you do edit it directly then just synchronize it again with npm i


rdelva
TRIALOP

2 years ago

nods


rdelva
TRIALOP

2 years ago

understood.. have a wonderful day and bless you 🙂


2 years ago

Thank you, you too :)


Loading...