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
2 years ago
please share your repo
this was the green deployment yesterday
https://railway.app/project/d85df9df-e8f2-42e7-81ea-4e1929823be4/service/04f7bad6-9243-4163-81f6-648ad8ec8daf?id=1159acdc-9143-4376-b5f2-f62b0b9ee70c
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
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?
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
2 years ago
Please verify that the package.json has a valid "main" entry
2 years ago
please provide a build log from the working build. and then a build log from the most recent broken build.
2 years ago
that is the deploy logs, please provide build logs
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
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?
2 years ago
can you revert your repo to the point in time the last successful deployment was made?
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)
2 years ago
you reverted the repo to before feb 28th?
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 😄
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
2 years ago
would you happen to know the node version in use by the last working build?
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
2 years ago
that runs the command locally
2 years ago
does the package.json have a valid main entry now?
2 years ago
would you be willing to add me to the repo?
2 years ago
brody192
2 years ago
what branch is railway set to deploy from?
2 years ago
is dist/main.js
the correct path to the generated file?
2 years ago
is this the path the main.js file ends up being put locally?
2 years ago
wait why is date-fns being used?
2 years ago
have you told me your local node version?
2 years ago
as far as i know, railway would be using node 18.19
2 years ago
just some tiny config issue, its a tricky one
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?
2 years ago
updating the target in your tsconfig.json to es2020 eh?
2 years ago
awsome, see, just a tiny misconfiguration
2 years ago
no problem, happy you where able to solve this
2 years ago
feel free to remove me from th github repo 🙂
im your latest supporter 😄 https://www.buymeacoffee.com/brody192/c/8685971
2 years ago
i was trying to figure out who that was lol
thank you for the train!
Actually this already happen yesterday. I didn't notice the failed build. This is the build log yerterday. it shows network error.
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?
2 years ago
that does not clear the cache on railway
2 years ago
that runs a local command
2 years ago
so the latest build is failing because it can't find date-fns?
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
2 years ago
add me back to the repo?
2 years ago
what branch is currently set to deploy to railway?
2 years ago
I've probably asked you this before, but you do use yarn locally right?
2 years ago
what version?
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
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
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.
2 years ago
is the install command listed as npm ci
?
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
2 years ago
in the build table at the top of the build logs
2 years ago
yeah this might be a cache issue
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
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
2 years ago
I agree
2 years ago
that's fair
2 years ago
happy to help!
ohh just fyi. i removed no cache and it fails again. seems I can't use cache for now hehe
2 years ago
the cache on the host machine is likely in a bad state, best to keep the no cache variable