#Issue with date-fns package

163 messages · Page 1 of 1 (latest)

hoary cave
#

anyone recently having issue with date-fns in railway? my latest deployment is not working due to error

Error: Cannot find module '/app/node_modules/date-fns/index.js'. Please verify that the package.json has a valid "main" entry

But checking the node_modules manually. the packages files including index.js is found

What's weird is that, this only happen today. yesterday the deployment work fine

weary grottoBOT
#

Project ID: d85df9df-e8f2-42e7-81ea-4e1929823be4

hoary cave
#

d85df9df-e8f2-42e7-81ea-4e1929823be4

cedar hamlet
#

please share your repo

hoary cave
#

no changes with the packages today

#

when i rollback to that build its working

#

the strange is that, there is no other update really. and if i try to re deploy using the same code base (no update) the issue will show up

#

is there any issue with the build just today?

cedar hamlet
#

this is unlikely to be a specific railway issue

#
Error: Cannot find module '/app/node_modules/date-fns/index.js'. Please verify that the package.json has a valid "main" entry
Please verify that the package.json has a valid "main" entry

have you done this?

#

another reason this could be happening, are you commiting your node_modules folder to github?

hoary cave
#

No, im not comitting node_modules to github

#

yeah, I thought of that as well that its not a railway issue. but what bugs me is that it just happen with todays deployments

#

btw, this is a nestjs project

cedar hamlet
#
Please verify that the package.json has a valid "main" entry
hoary cave
#

oh yeah there's none. I will try to add

#

same

#

think that error points to date-fns package

cedar hamlet
hoary cave
cedar hamlet
#

that is the deploy logs, please provide build logs

hoary cave
#

ohh

#

im seeing "No build logs found for deployment" with working build. few min I will revert to this build and see if build logs will be populated

cedar hamlet
#

sounds good

#

in the mean time, please send the build logs for the newest broken build

hoary cave
#

done reverting the working build. I see "No build logs found for deployment" still. maybe this is because it has been build before and was pulled from cache now?

#

ok let me pull up the latest build logs with current with error

cedar hamlet
#

can you revert your repo to the point in time the last successful deployment was made?

hoary cave
#

I did that earlier and able to experienced the issue. but I will try again now for you

cedar hamlet
#

do you have the date from when you made the last successful deployment? (not a revert)

hoary cave
#

it was on Feb 28, 2024 10:10 pm

#

btw, I just revert my repo to last working build

#

and it fails

cedar hamlet
#

you reverted the repo to before feb 28th?

hoary cave
#

on i've reverted on that date(feb 28). that's the first time I deploy this project in railway

#

btw, a note as well. I have other project using date-fns deployed in railway - been running almost a year already

#

now with this error. im afraid if we deploy to the other project might have the same issue 😄

cedar hamlet
#

can you try deleting your yarn lock file and then re-syncing it

#

you can bring your repo back up to date now

hoary cave
cedar hamlet
#

would you happen to know the node version in use by the last working build?

hoary cave
#

hmm no

#

but earlier while debuggin. I logged in server from my local using cli. I checked the node version in server and setup the same version in my local. Im not able to experience the same error in my local

cedar hamlet
#

the cli does not allow you to "log in" to the container

#

you where running commands locally

hoary cave
#

ohh

#

I was running railway run node -v thought that's from server

cedar hamlet
#

that runs the command locally

hoary cave
#

ok, thanks for correcting

cedar hamlet
#

does the package.json have a valid main entry now?

hoary cave
#

ahh updating back. was reverted earlier

#

updated. same error

cedar hamlet
#

would you be willing to add me to the repo?

hoary cave
#

sure yeah

#

pls share your github email I will give you read access

cedar hamlet
#

brody192

hoary cave
#

ok let me add you

#

added you already

cedar hamlet
#

what branch is railway set to deploy from?

hoary cave
#

develop

cedar hamlet
#

is dist/main.js the correct path to the generated file?

hoary cave
#

ohh wait let me double check

#

ohhh should be dist/src/main.js 🤦‍♂️

#

will try to deploy

cedar hamlet
hoary cave
#

yeah for yarn build command

hoary cave
cedar hamlet
#

wait why is date-fns being used?

hoary cave
#

for my date helpers. thats found in src/utils/date.ts

cedar hamlet
#

have you told me your local node version?

hoary cave
#

im currently using 18.18.1

cedar hamlet
#

as far as i know, railway would be using node 18.19

hoary cave
#

ohh ok. I can update

#

I can't see any obvious reasons why this error is showing and only in railway

cedar hamlet
#

just some tiny config issue, its a tricky one

hoary cave
#

hmm yeah

cedar hamlet
#

your start script is nest start are you sure this is running the built main.ts file?
maybe try changing your start command on railway to your start:prod script?

hoary cave
#

did that already

#

and the build I set to yarn build

#

ohh2 it seems working already with my latest push

cedar hamlet
#

updating the target in your tsconfig.json to es2020 eh?

hoary cave
#

yeah

#

seems that fixed it

cedar hamlet
#

awsome, see, just a tiny misconfiguration

hoary cave
#

haha thank you so much for the help!

cedar hamlet
#

no problem, happy you where able to solve this

#

feel free to remove me from th github repo 🙂

hoary cave
#

will remove you in the repo

cedar hamlet
#

i was trying to figure out who that was lol
thank you for the train!

hoary cave
#

lol

#

sure, welcome

weak moatBOT
hoary cave
#

Hi @cedar hamlet im seeing the issue again. nothing is changed in my end

#

I mean no updates for compiler hahaha

#

question, does railway randomly change their builder?

#

Actually this already happen yesterday. I didn't notice the failed build. This is the build log yerterday. it shows network error.

#

it's givin me headache already hahaha

#

can't focus on my development lol

cedar hamlet
#

first build log is for an issue with date-fns, second build log is an issue with cache, what is the current issue you get?

hoary cave
#

the issue with date-fns is the latest

#

hmm I will try to clear cache by running railway run yarn cache clean

cedar hamlet
#

that does not clear the cache on railway

hoary cave
#

ohh ok

cedar hamlet
#

that runs a local command

hoary cave
#

ok

cedar hamlet
#

so the latest build is failing because it can't find date-fns?

hoary cave
#

yeah same as before the one fixed already with changing tsconfig > target > 2022

#

is there a way to know what node version or how railway build? what i know only is that its using nixpacks

cedar hamlet
#

node 18, printed at the top of the build logs

#

have you modified your package.json? this is a different error from before, this time it just looks like it's outright not being installed

hoary cave
#

no nothing

cedar hamlet
#

add me back to the repo?

hoary cave
#

sure2

#

added

cedar hamlet
#

what branch is currently set to deploy to railway?

hoary cave
#

develop

#

these are test commits I did to try to fix the issue after the error build

cedar hamlet
#

I've probably asked you this before, but you do use yarn locally right?

hoary cave
#

yeah i use yarn in my local

cedar hamlet
#

what version?

hoary cave
#

v1.22.21

cedar hamlet
#

okay close enough to what railway uses

#

can you delete the lock file, and then regenerate it, let me know if git says it has changed

hoary cave
#

ok. I did that already earlier tho

#

nothing change

cedar hamlet
#

so how opposed would you be to switching to just npm as a test? (I'm running out of ideas)

#

aka delete your yarn lock file and generate an npm lock file with npm install

hoary cave
#

hmm been a while since i use npm 😄 tho I will try if that solve the issue

cedar hamlet
# hoary cave question, does railway randomly change their builder?

and to answer this question, yes they do, not intentionally, they rebase the image to get some os level security updates and sometimes they change the version of nix being used and that also can cause issues. but railway has not changed the builder since we last talked.

hoary cave
#

ok cool. noted

#

btw, deploying with npm

cedar hamlet
#

is the install command listed as npm ci?

hoary cave
hoary cave
#

ohh npm works

#

build is green

cedar hamlet
hoary cave
#

i'll try yarn now if it fail again

hoary cave
cedar hamlet
#

yeah this might be a cache issue

hoary cave
#

deploying now with yarn using no cache option

#

nah it worked 😄

#

I guess caching needs to be fixed by railway. for now, I will add no cache whenever I experienced this issue

#

this is not good tho. we choose railway so can just focus directly on development with 0 configs on server

#

Thank you! it's good chatting with someone with your knowledge. I get ideas hehe

cedar hamlet
#

while this particular experience is not good, from personal experience, unfortunately there is no such thing as zero configuration deployments, on any platform

hoary cave
#

yeah agree but something like this error is kind of frustrating 😄

cedar hamlet
#

I agree

hoary cave
#

or railway might add this as a note in the docs

cedar hamlet
#

that's fair

hoary cave
#

i'll remove you from repo now. Have a great day ahead. Thank you for your help!

cedar hamlet
#

happy to help!

hoary cave
#

ohh just fyi. i removed no cache and it fails again. seems I can't use cache for now hehe

#

if you have any updte on the caching pls let me know