0
0
JavascriptHow-ToBeginner · 3 min read

How to Install Node.js for JavaScript Development

To install Node.js, download the installer from the official website https://nodejs.org and run it on your computer. After installation, verify it by running node -v in your terminal to check the installed version.
📐

Syntax

Node.js installation is done outside JavaScript code using command line or installers. The main commands to check Node.js after installation are:

  • node -v: Shows the installed Node.js version.
  • npm -v: Shows the installed Node Package Manager version.

These commands help confirm Node.js is installed correctly.

bash
node -v
npm -v
Output
v20.4.0 9.8.1
💻

Example

This example shows how to check if Node.js is installed and run a simple JavaScript file using Node.js.

javascript
console.log('Hello from Node.js!');
Output
Hello from Node.js!
⚠️

Common Pitfalls

Common mistakes when installing Node.js include:

  • Not downloading from the official site https://nodejs.org, risking unsafe versions.
  • Not restarting the terminal after installation, so commands like node are not recognized.
  • Confusing Node.js with browser JavaScript; Node.js runs JavaScript outside the browser.

Always verify installation by running node -v and npm -v.

bash
wrong: node -v (before installation)
right: node -v (after installation)
Output
bash: node: command not found v20.4.0
📊

Quick Reference

Summary tips for installing Node.js:

  • Download from https://nodejs.org.
  • Choose the LTS version for stability.
  • Run the installer and follow prompts.
  • Restart your terminal after installation.
  • Verify with node -v and npm -v.

Key Takeaways

Download Node.js from the official website to ensure safety and latest version.
Run the installer and restart your terminal to enable Node.js commands.
Verify installation by checking Node.js and npm versions with command line.
Node.js allows running JavaScript outside the browser for server-side development.
Always use the LTS version for better stability and support.