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
Project ID:
4aeda38b-bc00-4f1e-b7f2-16b66f34371f
4aeda38b-bc00-4f1e-b7f2-16b66f34371f
might be a node v18.x.x and above thing
set
engines.node
= 18 in your package.jsonI’ll try it, thank you
still getting the same issue, i believe i added it correct?
nope, engines is an object, hence the period between engines and node
in dependencies then?
what no
idfk 💀
skull emoji is right
also, you don't even have a start script
this was my first project in node js lmao, apolgise in advance
okay so set
engines.node
= 18?
ay there you go
thank fuck for google
also, what node version do you have on your computer
20.2.0
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
i appreciate that lmao, better to force it than to feed it
alr, ill try it after
damn I'm dumb, railway only goes to 18
so double scratch that, keep it at 18
lmfao alr
what did you do lol, send the full package.json
got work so im rushing as well
ain't no way
remove the string "engines.node" from the dependencies object
and then send your package.json again
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?
install the lts version of node 18 on your computer and see how that goes
done so, works on the local machine
your code works locally with node 18?
yes
18.16
show me a screenshot of your service variables please
i assume you mean these?
not even close
the railway service variables
Oh right lol
where is your discord bot id thing
In a config file
you don't wanna store sensitive information in plaintext
but that's besides the point
Well yes but it’s not a big issue at this point
can't read properties of undefined, when on railway, is this a intermittent issue or..?
Only when using railway
but is it an intermittent error
Happens every time I try run a command which writes to a JSON file
and why are you writing to a JSON file?
Storing information between different applications
I can't see how that would work out on railway, railway doesn't have persistent storage
Luna please save me
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?
I was grasping at straws 🥹
We need the full error and more of the code.
@harryg0 if you can post that we should be able to resolve this.
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 😵💫
what?
unfortunate
Lmfao
go to the link it gave you in that message
Yeh looks like I’ll have to verify GitHub
sounds good