Get the number of CPU cores in Node.js

Last updated on May 28, 2020 A Goodman Loading... Post a comment

Node has a built-in module called os that can help you find out how many cores your CPU has.

Example:

const os = require('os');

const coreNumber = os.cpus().length;

// Printing the number of CPU cores
console.log(coreNumber);        

Related Articles

guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x