Back to Course
Development

Setting Up VS Code & REPL Terminal for Node.js Development

Your development environment is where you'll spend the majority of your time as a Node.js developer. Visual Studio Code (VS Code) is the most popular code editor for Node.js development — and for good reason. Combined with the Node.js REPL (Read-Eval-Print Loop), you have a powerful setup for building, testing, and debugging applications.

Production Reality: A well-configured IDE with proper extensions, debugging setup, and linting rules will catch errors before they reach production. The time invested in setting up your development environment is one of the highest-ROI activities you can do.

1. Why VS Code for Node.js?

  • Free & Open Source: No licensing costs, active community.
  • Excellent Node.js Integration: Built-in debugging, terminal, and Git support.
  • Massive Extension Ecosystem: Thousands of extensions for every need.
  • Cross-Platform: Works on Windows, macOS, and Linux.
  • Lightweight: Fast startup and low memory usage.
  • IntelliSense: Smart code completion for JavaScript/TypeScript.

2. Installing VS Code

PlatformMethodCommand/Download
WindowsOfficial InstallerDownload from code.visualstudio.com
macOSOfficial Installer / Homebrewbrew install --cask visual-studio-code
Linux (Ubuntu/Debian)Debian Packagesudo dpkg -i code_*.deb or Download .deb
Linux (Snap)Snapsudo snap install --classic code

3. Essential VS Code Extensions for Node.js

These extensions will dramatically improve your Node.js development experience:

ExtensionDescriptionPublisher
ESLintJavaScript linting (find and fix problems)Microsoft
PrettierCode formatter (consistent code style)Prettier
NPM IntelliSenseAuto-completes npm module importsChristian Kohler
Node.js ModulesAuto-completion for Node.js core modulesLeetCode
REST ClientTest APIs directly from VS CodeHuachao Mao
GitLensGit history, blame annotations, and moreGitKraken
Thunder ClientAPI testing (Postman alternative)Ranga Vadhineni
DotENVSyntax highlighting for .env filesmikestead
Better CommentsColor-coded comments (TODO, FIXME)Aaron Bond
Error LensInline error highlightingUsernamehw

How to Install Extensions

# From command line
code --install-extension ms-vscode.vscode-typescript-next
code --install-extension esbenp.prettier-vscode
code --install-extension dbaeumer.vscode-eslint

# Or search by name in VS Code's Extensions panel (Ctrl+Shift+X)

4. VS Code Settings for Node.js

Add these settings to your settings.json file for an optimized Node.js development experience:

{
    // Format on save
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode",

    // ESLint auto-fix on save
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true
    },

    // Use Node.js for terminals
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",

    // Auto-import suggestions
    "typescript.suggest.autoImports": true,
    "javascript.suggest.autoImports": true,

    // Show npm scripts in explorer
    "npm.enableScriptExplorer": true,

    // Auto-close tags (HTML/JSX)
    "html.autoClosingTags": true,
    "javascript.autoClosingTags": true,
    "typescript.autoClosingTags": true
}

5. Debugging Node.js Applications in VS Code

VS Code has built-in debugging support for Node.js. You can debug with breakpoints, step through code, inspect variables, and view the call stack.

Method 1: Run & Debug (Auto-attach)

  1. Open your Node.js project in VS Code.
  2. Press Ctrl+Shift+D (or Cmd+Shift+D on macOS) to open the Debug panel.
  3. Click the "Run and Debug" button and select "Node.js".
  4. VS Code will automatically attach to your Node.js process.

Method 2: Configure launch.json

Create a .vscode/launch.json file for more control:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/index.js",
            "console": "integratedTerminal",
            "envFile": "${workspaceFolder}/.env",
            "args": ["--max-old-space-size=4096"]
        },
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Process",
            "port": 9229,
            "restart": true,
            "skipFiles": ["/**"]
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Jest Tests",
            "program": "${workspaceFolder}/node_modules/jest/bin/jest",
            "args": ["--runInBand"],
            "console": "integratedTerminal"
        }
    ]
}

Debugging with Breakpoints

To set a breakpoint: Click in the gutter (left margin) next to a line number. A red dot will appear.

To start debugging: Press F5 or click the green play button.

To step through: Use F10 (Step Over), F11 (Step Into), or Shift+F11 (Step Out).

To inspect variables: Hover over any variable in the editor or view the VARIABLES panel.

6. Integrated Terminal in VS Code

The integrated terminal allows you to run npm commands, start your Node.js server, and execute scripts without leaving the editor.

  • Open terminal: Ctrl+` (or Cmd+` on macOS)
  • Create a new terminal: Ctrl+Shift+`
  • Split terminal: Ctrl+Shift+5
  • Run npm scripts: Click the "Run" icon that appears above npm scripts in package.json

7. The Node.js REPL (Read-Eval-Print Loop)

The REPL is an interactive shell where you can execute JavaScript code instantly. It's perfect for testing snippets, experimenting with Node.js APIs, and debugging on the fly.

Starting the REPL

# In your terminal
node

# You'll see:
# Welcome to Node.js v22.x.x.
# Type ".help" for more information.
# >

Basic REPL Usage

// Simple arithmetic
> 2 + 2
4

// Variables
> const greeting = 'Hello, Node.js!';
undefined
> greeting
'Hello, Node.js!'

// Functions
> const add = (a, b) => a + b;
undefined
> add(5, 3)
8

// Arrays & Objects
> const user = { name: 'John', age: 30 };
undefined
> user.name
'John'

REPL Features

FeatureDescriptionExample
AutocompletePress Tab to autocompleteconsconsole
Editor ModeWrite multi-line code.editor
Load FileLoad and execute a file.load app.js
Save SessionSave REPL session to file.save session.txt
HelpShow available commands.help
ExitExit REPL.exit or Ctrl+C twice

Using .editor Mode

Write multi-line functions easily in the REPL:

> .editor
// Entering editor mode (Ctrl+D to finish)
function calculateTotal(items) {
    return items.reduce((sum, item) => sum + item.price, 0);
}

// Calculate total
const cart = [{ price: 10 }, { price: 20 }, { price: 30 }];
calculateTotal(cart);

// Output after Ctrl+D:
// 60
> 

Loading Files in REPL

// Load and execute a JavaScript file
> .load app.js
// Output: [file content and execution results]

// Load a module
> const fs = require('fs');
undefined
> fs.readFileSync('.help') // Shows help content

Using REPL for Quick Testing

// Test a regular expression
> const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
undefined
> regex.test('user@example.com')
true
> regex.test('invalid-email')
false

// Test a Node.js API
> const path = require('path');
undefined
> path.join('/user', 'docs', 'file.txt')
'/user/docs/file.txt'
> path.extname('file.txt')
'.txt'

8. VS Code Extensions for REPL Enhancement

ExtensionDescription
Code RunnerRun code snippets directly in VS Code
Quokka.jsReal-time code execution feedback
JavaScript REPLRun JavaScript in VS Code's integrated terminal
Node.js REPLNode.js REPL inside VS Code

9. Common Issues & Solutions

Issue 1: "command not found: node" in VS Code terminal

Solution: VS Code uses your system's PATH. Restart VS Code after installing Node.js. If it persists:

  • Windows: Add Node.js to your PATH in System Environment Variables.
  • macOS/Linux: Check if Node.js is in your shell profile (echo $PATH).

Issue 2: ESLint not working

Solution: Make sure ESLint is installed locally (npm install eslint --save-dev). Install the ESLint extension and run npx eslint --init to generate config.

Issue 3: Debugger not attaching

Solution: Start your Node.js application with the --inspect flag:

node --inspect app.js
# Or with a specific port
node --inspect=9229 app.js

Then use the "Attach to Process" configuration in launch.json.

10. Production-Ready Checklist

  • ✅ Install VS Code — Latest version from code.visualstudio.com.
  • ✅ Install essential extensions — ESLint, Prettier, GitLens, npm IntelliSense.
  • ✅ Configure ESLintnpx eslint --init and add rules.
  • ✅ Set up Prettier — Add .prettierrc and format on save.
  • ✅ Configure launch.json — Set up debugging configurations.
  • ✅ Add .vscode folder — Share settings with your team.
  • ✅ Use integrated terminal — Run npm commands without leaving VS Code.
  • ✅ Master the REPL — Use it for testing and exploration.
  • ✅ Install Git — Version control is essential.
  • ✅ Set up .gitignore — Exclude node_modules/, .env, and dist/.
  • ✅ Use workspace settings — Project-specific settings in .vscode/settings.json.
  • ✅ Enable auto-save — Reduces the risk of losing changes.

11. Quick Reference — VS Code Shortcuts for Node.js Developers

ShortcutAction
Ctrl+` (Cmd+`)Open Integrated Terminal
Ctrl+Shift+DOpen Debug Panel
F5Start Debugging
Ctrl+Shift+XOpen Extensions Panel
Ctrl+PQuick Open (find files)
Ctrl+Shift+PCommand Palette
Ctrl+SpaceTrigger IntelliSense
F12Go to Definition
Shift+F12Find All References
Ctrl+Shift+FSearch Across Files
Production Wisdom: Your development environment is your cockpit. A well-configured VS Code setup with linting, formatting, and debugging will make you significantly more productive. The REPL is a powerful tool for testing and exploration — use it often to validate your code before writing full files.

Ready to master Node.js?

Build scalable, high-performance backend applications with Node.js. Learn from industry experts with hands-on projects.

Explore Course