Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node cluster.isPrimary is undefined

Node says that cluster.isMaster is deprecated and we should use cluster.isPrimary. But, while isMaster is returning me true without problem, I getting undefined when I try cluster.isPrimary:

const cluster = require("cluster");

console.log(cluster.isPrimary); /// undefined

console.log(cluster.isMaster); /// true

Why is this happening?

like image 574
bahejam379 Avatar asked Sep 02 '26 19:09

bahejam379


2 Answers

Use node v16+ and add "esModuleInterop": true into tsconfig.json file.

like image 157
Ion Leu Avatar answered Sep 04 '26 09:09

Ion Leu


Make sure you are on at least Node version 16.0.0

you can see this by running this command in your terminal:

node --version
like image 44
about14sheep Avatar answered Sep 04 '26 09:09

about14sheep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!