JavaScript Setup & Environment

Get your JavaScript development environment ready. Start in 60 seconds with the browser console, or set up Node.js and VS Code for full-stack development.

Beginner 5 min read 3 examples

Option 1: Browser Console (Instant, No Install)

The fastest way to run JavaScript is already in your browser. Every modern browser ships with a full JavaScript runtime and developer tools.

  1. Open Google Chrome or Firefox
  2. Press F12 (Windows/Linux) or Cmd+Option+J (Mac)
  3. Click the Console tab
  4. Type console.log("Hello!") and press Enter
JavaScript Browser Console
// Type these in the browser console:
console.log("Hello, World!");
console.log(2 + 2);
console.log(typeof "hello");

// Multi-line object inspection
const user = { name: "Alex", age: 28 };
console.log(user);
Hello, World! 4 string {name: 'Alex', age: 28}
Console Shortcuts
  • console.log() - print values
  • console.error() - print errors (red)
  • console.table() - print arrays/objects as a table
  • Shift+Enter - new line without running (for multi-line code)
  • Arrow Up / Down - navigate command history

Option 2: Install Node.js (Run JS Anywhere)

Node.js lets you run JavaScript files from the terminal - no browser needed. It also comes with npm, which you will need for installing packages.

Install Steps (Windows / Mac / Linux)

  1. Go to nodejs.org and download the LTS version (Node 20+)
  2. Run the installer and follow the prompts (default settings are fine)
  3. Open a terminal and verify the install:
Bash Terminal
node --version   # should print v20.x.x or higher
npm --version    # should print 10.x.x or higher
Use nvm for Multiple Node Versions

If you work on multiple projects needing different Node versions, install nvm (Node Version Manager) instead of installing Node directly. It lets you switch between versions: nvm install 20, nvm use 20.

VS Code Setup for JavaScript

Visual Studio Code is the industry-standard editor for JavaScript development. It is free, fast, and has excellent built-in JavaScript support.

Install VS Code

  1. Download from code.visualstudio.com and install
  2. Open VS Code and install these extensions:
ExtensionPurpose
ESLintCatches code errors and style issues as you type
PrettierAuto-formats code on save (consistent style)
GitLensEnhanced Git integration
Path IntellisenseAutocomplete file paths in import statements
Live ServerAuto-reload browser when you save HTML/JS files

Configure Auto-format on Save

Open VS Code settings (Ctrl+,) and add these to settings.json:

JSON .vscode/settings.json
{
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.tabSize": 2,
    "javascript.preferences.quoteStyle": "single"
}

Run Your First JS File

Create a file called hello.js and run it with Node.js:

JavaScript hello.js
const name = "RubanLearn";
const year = new Date().getFullYear();

console.log(`Welcome to ${name}!`);
console.log(`Learning JavaScript in ${year}.`);

// Simple function
function greet(person) {
    return `Hello, ${person}!`;
}

console.log(greet("Developer"));
Bash Terminal
node hello.js
Welcome to RubanLearn! Learning JavaScript in 2024. Hello, Developer!

package.json Basics

Every Node.js project has a package.json file that tracks the project name, version, and dependencies. Create one with:

Bash Terminal
mkdir my-project && cd my-project
npm init -y          # creates package.json with defaults
npm install lodash   # install a package (example)

Online Editors (No Install)

For quick experiments without any local setup:

  • CodePen - best for HTML/CSS/JS experiments with live preview
  • JSFiddle - classic JS sandbox, easy to share
  • StackBlitz - full VS Code in the browser, supports Node.js projects
  • Replit - full development environment, supports Node.js
  • PlayCode.io - fast JS playground with instant output
Recommendation for This Tutorial

For following along with this tutorial: use the browser console for the first few lessons (variables, data types, operators), then switch to VS Code + Node.js when you reach DOM and async topics.

Frequently Asked Questions

No - you can start immediately using the browser console (F12 in Chrome). Node.js is needed if you want to run JavaScript outside the browser, use npm packages, or build backend apps. For pure frontend learning, the browser console and a simple HTML file are all you need.

Always install the LTS (Long-Term Support) version. As of 2024, that is Node.js 20 LTS. LTS versions are stable and supported for 3 years. Avoid odd-numbered versions (19, 21) for production - they are "current" releases with shorter support windows.

npm (Node Package Manager) comes bundled with Node.js. It lets you install third-party packages (libraries) into your project. You will need it once you start using frameworks like React, or tools like Webpack. For basic JavaScript learning, you do not need it yet.

Essential: ESLint (code linting), Prettier (formatting), and GitLens. For later: ES7+ React/Redux snippets if you move to React. VS Code has built-in IntelliSense for JavaScript, so you do not need a separate language server extension.