Hey Everyone ๐. It's Caesar. Let's Activate your Super Power.
With just few lines of code you have super powers from the ordinary man, who goes to his system settings in search for his OS details. let's activate that super power. Shall we?
As a prerequisite,
- you need to have node install in your system.
.
Come Nodejs, comes your super power tool - THE OS module
This gives us the information of our operating system. Enough Talk, lets activate the super power.
Open your favorite editor and create a app.js file. Input the code as shown below:
// No npm install is needed
const os = require('os');
// Object holding the key-value pair of the
![os.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1616981815534/XN32uHhhe.png)
operating system information
const currentSystemOs = {
name: os.type(),
version: os.version(),
release: os.release(),
info: os.userInfo(),
totalMemory: os.totalmem(),
freeMemory : os.freemem(),
}
console.log(currentSystemOs);
Next, Open your Terminal, If your favorite editor is VS-CODE, use ctrl + backtick to open its integrated terminal, otherwise use your command line navigating to file path. Enter the following to run the code.
node app.js
And just like that, you activated your super power and you should see your system OS Details.
{
name: 'Windows_NT',
version: 'Windows 10 Pro',
release: '10.0.19042',
totalMemory: 8465244160,
freeMemory: 4119216128,
freeMemory: 4119216128,
info: {
uid: -1,
gid: -1,
username: 'USER',
homedir: 'C:\\Users\\USER',
shell: null
}
}
Want to explore more on your super power tools. check out :
THANKS FOR READING!!!