Categories
JavaScript Answers

How to get number of processors available with Node.js?

Spread the love

Sometimes, we want to get number of processors available with Node.js.

In this article, we’ll look at how to get number of processors available with Node.js.

How to get number of processors available with Node.js?

To get number of processors available with Node.js, we can use the os.cpus method.

For instance, we write

const os = require("os");
const cpuCount = os.cpus().length;

to get the cpuCount with os.cpus().length.

Conclusion

To get number of processors available with Node.js, we can use the os.cpus method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *