Using os.platform() and os.arch() in Node.js
📖 Scenario: You are creating a simple Node.js script that detects the operating system platform and CPU architecture of the computer it runs on. This information can help your program adjust its behavior depending on the environment.
🎯 Goal: Build a Node.js script that uses the os module to get the platform and architecture, then stores these values in variables.
📋 What You'll Learn
Import the built-in
os moduleCreate a variable called
platform that stores the result of os.platform()Create a variable called
architecture that stores the result of os.arch()Use only the exact variable names and method calls as specified
💡 Why This Matters
🌍 Real World
Detecting the operating system and CPU architecture helps software adjust behavior, like choosing the right binaries or enabling platform-specific features.
💼 Career
Many Node.js jobs require working with system information for deployment scripts, cross-platform tools, or environment-aware applications.
Progress0 / 4 steps