4 months 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?
0 Replies
4 months 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?
4 months ago
after cleaning your modules and re-installing?
4 months ago
Not personally sure, my node knowledge is weak - so, check nestjs/schedule is up to date.
Will let someone else take a stab.
4 months ago
stupid one: did you import/define it it?
4 months ago
Are you using nixpacks or your own dockerfile?
4 months ago
If so, nixpacks defaults to Node 18 according to docs
4 months ago
and this is in a server component?
4 months ago
override it with some of the options shown here and try building again
4 months ago
the crypto
package was only globally available in node in version >=19 afaik
4 months ago
thank you medim!
4 months ago
!s
Status changed to Solved brody • 4 months ago