Issue with date-fns package

asproPRO

a year 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

asproPRO

a year ago

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


a year ago

please share your repo


asproPRO

a year ago

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



asproPRO

a year ago

no changes with the packages today


asproPRO

a year ago

when i rollback to that build its working


asproPRO

a year 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


asproPRO

a year ago

is there any issue with the build just today?


a year ago

this is unlikely to be a specific railway issue


a year 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?


a year ago

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


asproPRO

a year ago

No, im not comitting node_modules to github


asproPRO

a year 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


asproPRO

a year ago

btw, this is a nestjs project


a year ago

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

asproPRO

a year ago

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


asproPRO

a year ago

same


asproPRO

a year ago

think that error points to date-fns package


a year ago

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


asproPRO

a year ago

working build


a year ago

that is the deploy logs, please provide build logs


asproPRO

a year ago

ohh


asproPRO

a year 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


a year ago

sounds good


a year ago

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


asproPRO

a year 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?


asproPRO

a year ago

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


asproPRO

a year ago

one with error build


a year ago

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


asproPRO

a year ago

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


a year ago

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


asproPRO

a year ago

it was on Feb 28, 2024 10:10 pm


asproPRO

a year ago

btw, I just revert my repo to last working build


asproPRO

a year ago

and it fails


asproPRO

a year ago


a year ago

you reverted the repo to before feb 28th?


asproPRO

a year ago

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


asproPRO

a year ago

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


asproPRO

a year ago

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


a year ago

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


a year ago

you can bring your repo back up to date now


asproPRO

a year ago

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


a year ago

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


asproPRO

a year ago

hmm no


asproPRO

a year 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


a year ago

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


a year ago

you where running commands locally


asproPRO

a year ago

ohh


asproPRO

a year ago

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


a year ago

that runs the command locally


asproPRO

a year ago

ok, thanks for correcting


a year ago

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


asproPRO

a year ago

ahh updating back. was reverted earlier


asproPRO

a year ago

updated. same error


a year ago

would you be willing to add me to the repo?


asproPRO

a year ago

sure yeah


asproPRO

a year ago

pls share your github email I will give you read access


a year ago

brody192


asproPRO

a year ago

ok let me add you


asproPRO

a year ago

added you already



a year ago

what branch is railway set to deploy from?


asproPRO

a year ago

develop


a year ago

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


asproPRO

a year ago

ohh wait let me double check


asproPRO

a year ago

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


asproPRO

a year ago

will try to deploy


a year ago

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


asproPRO

a year ago

yeah for yarn build command


asproPRO

a year ago

done, same error


a year ago

wait why is date-fns being used?


asproPRO

a year ago

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


a year ago

have you told me your local node version?


asproPRO

a year ago

im currently using 18.18.1


a year ago

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


asproPRO

a year ago

ohh ok. I can update


asproPRO

a year ago

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


a year ago

just some tiny config issue, its a tricky one


asproPRO

a year ago

hmm yeah


a year 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?


asproPRO

a year ago

did that already


asproPRO

a year ago

and the build I set to yarn build


asproPRO

a year ago

ohh2 it seems working already with my latest push


a year ago

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


asproPRO

a year ago

yeah


asproPRO

a year ago

seems that fixed it


a year ago

awsome, see, just a tiny misconfiguration


asproPRO

a year ago

haha thank you so much for the help!


a year ago

no problem, happy you where able to solve this


a year ago

feel free to remove me from th github repo 🙂


asproPRO

a year ago


asproPRO

a year ago

will remove you in the repo


a year ago

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


asproPRO

a year ago

lol


asproPRO

a year ago

sure, welcome


asproPRO

a year ago

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


asproPRO

a year ago

I mean no updates for compiler hahaha


asproPRO

a year ago

question, does railway randomly change their builder?


asproPRO

a year ago


asproPRO

a year ago

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


asproPRO

a year ago


asproPRO

a year ago

it's givin me headache already hahaha


asproPRO

a year ago

can't focus on my development lol


a year 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?


asproPRO

a year ago

the issue with date-fns is the latest


asproPRO

a year ago

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


a year ago

that does not clear the cache on railway


asproPRO

a year ago

ohh ok


a year ago

that runs a local command


asproPRO

a year ago

ok


a year ago

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


asproPRO

a year ago

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


asproPRO

a year ago

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


a year ago

node 18, printed at the top of the build logs


a year 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


asproPRO

a year ago

no nothing


a year ago

add me back to the repo?


asproPRO

a year ago

sure2


asproPRO

a year ago

added


a year ago

what branch is currently set to deploy to railway?


asproPRO

a year ago

develop


asproPRO

a year ago

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

1214954946663809000


a year ago

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


asproPRO

a year ago

yeah i use yarn in my local


a year ago

what version?


asproPRO

a year ago

v1.22.21


a year ago

okay close enough to what railway uses


a year ago

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


asproPRO

a year ago

ok. I did that already earlier tho


asproPRO

a year ago

nothing change


asproPRO

a year ago

1214956748989792300


a year ago

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


a year ago

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


asproPRO

a year ago

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


a year 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.


asproPRO

a year ago

ok cool. noted


asproPRO

a year ago

btw, deploying with npm


a year ago

is the install command listed as npm ci?


asproPRO

a year 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


asproPRO

a year ago

sorry didn't get you


asproPRO

a year ago

ohh npm works


asproPRO

a year ago

build is green


a year ago

in the build table at the top of the build logs


asproPRO

a year ago

i'll try yarn now if it fail again


asproPRO

a year ago

ahh yeah it is

1214958775358853000


a year ago

yeah this might be a cache issue


asproPRO

a year ago

deploying now with yarn using no cache option


asproPRO

a year ago

nah it worked 😄

1214960664817307600


asproPRO

a year ago

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


asproPRO

a year ago

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


asproPRO

a year ago

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


a year ago

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


asproPRO

a year ago

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


a year ago

I agree


asproPRO

a year ago

or railway might add this as a note in the docs


a year ago

that's fair


asproPRO

a year ago

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


a year ago

happy to help!


asproPRO

a year ago

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


asproPRO

a year ago

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


a year 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