Node version error

xcyth
PRO

7 months ago

I added an npm package to my code @nestjs/schedule which has a function using crypto.randomUUID which probably isnt supported in the current node version my railway instance is using? How can i change it?

View Deploy details

ⓘ Deployment information is only viewable by project members and Railway employees.

6 Replies

xcyth
PRO

7 months ago

Error stack:

```
/app/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:90

Jan 29 08:47:31

const name = options.name || crypto.randomUUID();

Jan 29 08:47:31

^

Jan 29 08:47:31

Jan 29 08:47:31

ReferenceError: crypto is not defined

Jan 29 08:47:31

at SchedulerOrchestrator.addCron (/app/node_modules/@nestjs/schedule/dist/scheduler.orchestrator.js:90:38)

Jan 29 08:47:31

at ScheduleExplorer.lookupSchedulers (/app/node_modules/@nestjs/schedule/dist/schedule.explorer.js:67:51)

Jan 29 08:47:31

at processMethod (/app/node_modules/@nestjs/schedule/dist/schedule.explorer.js:45:24)

Jan 29 08:47:31

at Array.forEach (<anonymous>)

Jan 29 08:47:31

at /app/node_modules/@nestjs/schedule/dist/schedule.explorer.js:54:18

Jan 29 08:47:31

at Array.forEach (<anonymous>)

Jan 29 08:47:31

at ScheduleExplorer.explore (/app/node_modules/@nestjs/schedule/dist/schedule.explorer.js:39:26)

Jan 29 08:47:31

at ScheduleExplorer.onModuleInit (/app/node_modules/@nestjs/schedule/dist/schedule.explorer.js:32:14)

Jan 29 08:47:31

at MapIterator.iteratee (/app/node_modules/@nestjs/core/hooks/on-module-init.hook.js:22:43)

Jan 29 08:47:31

at MapIterator.next (/app/node_modules/iterare/src/map.ts:9:39)

Jan 29 08:47:31

Jan 29 08:47:31

Node.js v18.20.5
```


xcyth
PRO

7 months ago

the exact same code works on my environment which is using v20.18.1


7 months ago

You can change the Node version by specifying your desired version in the engines.node field in your package.json


brody

You can change the Node version by specifying your desired version in the engines.node field in your package.json

xcyth
PRO

7 months ago

Thanks!


dhkim
PRO

6 months ago

I tried versioning engines.node on the same issue and got the following error

{
  ...
  "version": "0.0.1",
  "engines": {
    "node": "20.11.0"
  },
  "scripts": {
  ...

how can I fix it?


dhkim

I tried versioning engines.node on the same issue and got the following error{ ... "version": "0.0.1", "engines": { "node": "20.11.0" }, "scripts": { ...how can I fix it?

oleh-vorobets
TRIAL

6 months ago

version 22.11.0 helped me