Issue with date-fns package

aspro
PRO

2 years ago

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

0 Replies

aspro
PRO

2 years ago

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


2 years ago

please share your repo


aspro
PRO

2 years ago

hmm it's a private repo. but this is the package.json



aspro
PRO

2 years ago

no changes with the packages today


aspro
PRO

2 years ago

when i rollback to that build its working


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

is there any issue with the build just today?


2 years ago

this is unlikely to be a specific railway issue


2 years ago

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?


2 years ago

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


aspro
PRO

2 years ago

No, im not comitting node_modules to github


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

btw, this is a nestjs project


2 years ago

Please verify that the package.json has a valid "main" entry

aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

same


aspro
PRO

2 years ago

think that error points to date-fns package


2 years ago

please provide a build log from the working build. and then a build log from the most recent broken build.


aspro
PRO

2 years ago

working build


2 years ago

that is the deploy logs, please provide build logs


aspro
PRO

2 years ago

ohh


aspro
PRO

2 years ago

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


2 years ago

sounds good


2 years ago

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


aspro
PRO

2 years ago

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?


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

one with error build


2 years ago

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


aspro
PRO

2 years ago

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


2 years ago

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


aspro
PRO

2 years ago

it was on Feb 28, 2024 10:10 pm


aspro
PRO

2 years ago

btw, I just revert my repo to last working build


aspro
PRO

2 years ago

and it fails


aspro
PRO

2 years ago


2 years ago

you reverted the repo to before feb 28th?


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

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


2 years ago

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


2 years ago

you can bring your repo back up to date now


aspro
PRO

2 years ago

yeah actually done that as well earlier as well. I will do it again for you


2 years ago

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


aspro
PRO

2 years ago

hmm no


aspro
PRO

2 years ago

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


2 years ago

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


2 years ago

you where running commands locally


aspro
PRO

2 years ago

ohh


aspro
PRO

2 years ago

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


2 years ago

that runs the command locally


aspro
PRO

2 years ago

ok, thanks for correcting


2 years ago

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


aspro
PRO

2 years ago

ahh updating back. was reverted earlier


aspro
PRO

2 years ago

updated. same error


2 years ago

would you be willing to add me to the repo?


aspro
PRO

2 years ago

sure yeah


aspro
PRO

2 years ago

pls share your github email I will give you read access


2 years ago

brody192


aspro
PRO

2 years ago

ok let me add you


aspro
PRO

2 years ago

added you already



2 years ago

what branch is railway set to deploy from?


aspro
PRO

2 years ago

develop


2 years ago

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


aspro
PRO

2 years ago

ohh wait let me double check


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

will try to deploy


2 years ago

is this the path the main.js file ends up being put locally?


aspro
PRO

2 years ago

yeah for yarn build command


aspro
PRO

2 years ago

done, same error


2 years ago

wait why is date-fns being used?


aspro
PRO

2 years ago

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


2 years ago

have you told me your local node version?


aspro
PRO

2 years ago

im currently using 18.18.1


2 years ago

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


aspro
PRO

2 years ago

ohh ok. I can update


aspro
PRO

2 years ago

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


2 years ago

just some tiny config issue, its a tricky one


aspro
PRO

2 years ago

hmm yeah


2 years ago

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?


aspro
PRO

2 years ago

did that already


aspro
PRO

2 years ago

and the build I set to yarn build


aspro
PRO

2 years ago

ohh2 it seems working already with my latest push


2 years ago

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


aspro
PRO

2 years ago

yeah


aspro
PRO

2 years ago

seems that fixed it


2 years ago

awsome, see, just a tiny misconfiguration


aspro
PRO

2 years ago

haha thank you so much for the help!


2 years ago

no problem, happy you where able to solve this


2 years ago

feel free to remove me from th github repo 🙂


aspro
PRO

2 years ago


aspro
PRO

2 years ago

will remove you in the repo


2 years ago

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


aspro
PRO

2 years ago

lol


aspro
PRO

2 years ago

sure, welcome


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

I mean no updates for compiler hahaha


aspro
PRO

2 years ago

question, does railway randomly change their builder?


aspro
PRO

2 years ago


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago


aspro
PRO

2 years ago

it's givin me headache already hahaha


aspro
PRO

2 years ago

can't focus on my development lol


2 years ago

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?


aspro
PRO

2 years ago

the issue with date-fns is the latest


aspro
PRO

2 years ago

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


2 years ago

that does not clear the cache on railway


aspro
PRO

2 years ago

ohh ok


2 years ago

that runs a local command


aspro
PRO

2 years ago

ok


2 years ago

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


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

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


2 years ago

node 18, printed at the top of the build logs


2 years ago

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


aspro
PRO

2 years ago

no nothing


2 years ago

add me back to the repo?


aspro
PRO

2 years ago

sure2


aspro
PRO

2 years ago

added


2 years ago

what branch is currently set to deploy to railway?


aspro
PRO

2 years ago

develop


aspro
PRO

2 years ago

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

1214954946663809000


2 years ago

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


aspro
PRO

2 years ago

yeah i use yarn in my local


2 years ago

what version?


aspro
PRO

2 years ago

v1.22.21


2 years ago

okay close enough to what railway uses


2 years ago

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


aspro
PRO

2 years ago

ok. I did that already earlier tho


aspro
PRO

2 years ago

nothing change


aspro
PRO

2 years ago

1214956748989792300


2 years ago

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


2 years ago

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


aspro
PRO

2 years ago

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


2 years ago

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.


aspro
PRO

2 years ago

ok cool. noted


aspro
PRO

2 years ago

btw, deploying with npm


2 years ago

is the install command listed as npm ci?


aspro
PRO

2 years ago

hmm think might be cache. after this I will back to yarn and try this NO_CACHE option
https://docs.railway.app/guides/build-configuration


aspro
PRO

2 years ago

sorry didn't get you


aspro
PRO

2 years ago

ohh npm works


aspro
PRO

2 years ago

build is green


2 years ago

in the build table at the top of the build logs


aspro
PRO

2 years ago

i'll try yarn now if it fail again


aspro
PRO

2 years ago

ahh yeah it is

1214958775358853000


2 years ago

yeah this might be a cache issue


aspro
PRO

2 years ago

deploying now with yarn using no cache option


aspro
PRO

2 years ago

nah it worked 😄

1214960664817307600


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

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


2 years ago

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


aspro
PRO

2 years ago

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


2 years ago

I agree


aspro
PRO

2 years ago

or railway might add this as a note in the docs


2 years ago

that's fair


aspro
PRO

2 years ago

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


2 years ago

happy to help!


aspro
PRO

2 years ago

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


aspro
PRO

2 years ago

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


2 years ago

the cache on the host machine is likely in a bad state, best to keep the no cache variable


Issue with date-fns package - Railway Help Station