a year ago
I'm running a NestJS project on Railway and using @nestjs/schedule for task scheduling. Everything works fine locally, but when deployed to Railway, I get the following error:
ReferenceError: crypto is not defined at SchedulerOrchestrator.addCron (/app/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:90:38)
It seems that Railway's environment is not properly loading the native crypto module, which is available in Node.js 20+.
Has anyone encountered this issue before or knows how to force the crypto module to load properly on Railway?
24 Replies
a year ago
Can you clean your node modules locally to see if you have something cached that's misleading you into thinking your build is working?
a year ago
after cleaning your modules and re-installing?
a year ago
Not personally sure, my node knowledge is weak - so, check nestjs/schedule is up to date.
Will let someone else take a stab.
a year ago
stupid one: did you import/define it it?
a year ago
Are you using nixpacks or your own dockerfile?
a year ago
If so, nixpacks defaults to Node 18 according to docs
a year ago
and this is in a server component?
a year ago
override it with some of the options shown here and try building again
a year ago
the crypto package was only globally available in node in version >=19 afaik
a year ago
thank you medim!
a year ago
!s
Status changed to Solved brody • about 1 year ago

