Skip to content
Justice Tech School

The os Module

os tells you about the machine: platform, CPU count, memory and the temp folder. os.EOL is the right line ending.

Example
const os = require('node:os');
console.log(typeof os.cpus().length, typeof os.totalmem());
console.log(typeof os.tmpdir(), os.EOL === '\n');
console.log(['linux','darwin','win32'].includes(os.platform()));

Result

number number
string true
true

Exercise

Get the temp folder.

os.()

Quiz Test

What does os.EOL give?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.