Unable to use .splice or .push while using railway

Hello, recently started using Railway to host my discord bot, however upon use i found that I'm not able to use the .splice and .push methods for file reading, when this worked fine during local hosting. There is not much online regarding things like this, hence my reason for coming here. Thanks
57 Replies
Percy
Percy2y ago
Project ID: 4aeda38b-bc00-4f1e-b7f2-16b66f34371f
harryg0
harryg0OP2y ago
4aeda38b-bc00-4f1e-b7f2-16b66f34371f
Brody
Brody2y ago
might be a node v18.x.x and above thing set engines.node = 18 in your package.json
harryg0
harryg0OP2y ago
I’ll try it, thank you
harryg0
harryg0OP2y ago
still getting the same issue, i believe i added it correct?
Brody
Brody2y ago
nope, engines is an object, hence the period between engines and node
harryg0
harryg0OP2y ago
in dependencies then?
Brody
Brody2y ago
what no
harryg0
harryg0OP2y ago
idfk 💀
Brody
Brody2y ago
skull emoji is right also, you don't even have a start script
harryg0
harryg0OP2y ago
this was my first project in node js lmao, apolgise in advance
Brody
Brody2y ago
okay so set engines.node = 18
harryg0
harryg0OP2y ago
?
Brody
Brody2y ago
ay there you go
harryg0
harryg0OP2y ago
thank fuck for google
Brody
Brody2y ago
also, what node version do you have on your computer
harryg0
harryg0OP2y ago
20.2.0
Brody
Brody2y ago
I'm just here as a guide, you still gotta figure out all the little stuff damn node 20 scratch that, set the node version to 19, that's the highest railway goes
harryg0
harryg0OP2y ago
i appreciate that lmao, better to force it than to feed it alr, ill try it after
Brody
Brody2y ago
damn I'm dumb, railway only goes to 18 so double scratch that, keep it at 18
harryg0
harryg0OP2y ago
lmfao alr
harryg0
harryg0OP2y ago
Brody
Brody2y ago
what did you do lol, send the full package.json
harryg0
harryg0OP2y ago
got work so im rushing as well
Brody
Brody2y ago
ain't no way remove the string "engines.node" from the dependencies object and then send your package.json again
harryg0
harryg0OP2y ago
Oh shit 🤣🤣🤣 Didn’t even clock I left that shit in there 💀 still getting the same error. i assume due to the downgraded node version this is why?
Brody
Brody2y ago
install the lts version of node 18 on your computer and see how that goes
harryg0
harryg0OP2y ago
done so, works on the local machine
Brody
Brody2y ago
your code works locally with node 18?
harryg0
harryg0OP2y ago
yes 18.16
Brody
Brody2y ago
show me a screenshot of your service variables please
harryg0
harryg0OP2y ago
i assume you mean these?
Brody
Brody2y ago
not even close the railway service variables
harryg0
harryg0OP2y ago
Oh right lol
harryg0
harryg0OP2y ago
Brody
Brody2y ago
where is your discord bot id thing
harryg0
harryg0OP2y ago
In a config file
Brody
Brody2y ago
you don't wanna store sensitive information in plaintext but that's besides the point
harryg0
harryg0OP2y ago
Well yes but it’s not a big issue at this point
Brody
Brody2y ago
can't read properties of undefined, when on railway, is this a intermittent issue or..?
harryg0
harryg0OP2y ago
Only when using railway
Brody
Brody2y ago
but is it an intermittent error
harryg0
harryg0OP2y ago
Happens every time I try run a command which writes to a JSON file
Brody
Brody2y ago
and why are you writing to a JSON file?
harryg0
harryg0OP2y ago
Storing information between different applications
Brody
Brody2y ago
I can't see how that would work out on railway, railway doesn't have persistent storage Luna please save me
luna
luna2y ago
This is very likely nothing todo with node versions. splice and such are from ES5 which is before node. What are you trying to splice?
Brody
Brody2y ago
I was grasping at straws 🥹
luna
luna2y ago
We need the full error and more of the code. @harryg0 if you can post that we should be able to resolve this.
harryg0
harryg0OP2y ago
It’s probably my makeshift coding with the attitude of “if it ain’t broken don’t fix it” attitude 🤣 But yes I’ll send what I can At work currently so TypeError: Cannot read properties of undefined (reading 'splice') at Object.execute (/app/commands/rating/updateRating.js:68:28) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Client.<anonymous> (/app/index.js:57:9) Cannot get the code unfortunately But it spliced a current array with an updated array And the push added a new array in there If that’s what it’s called in json Unverified railway app now 😵‍💫
Brody
Brody2y ago
what?
harryg0
harryg0OP2y ago
Brody
Brody2y ago
unfortunate
harryg0
harryg0OP2y ago
Lmfao
Brody
Brody2y ago
go to the link it gave you in that message
harryg0
harryg0OP2y ago
Yeh looks like I’ll have to verify GitHub
Brody
Brody2y ago
sounds good
Want results from more Discord servers?
Add your server