dev/notes
⌕

Spot a mistake? Highlight any text in a post and click Report — it goes straight to the author.

← all posts
beginner · Development Environment · August 17, 2026 · 5 min read

How to Set Up a Modern JavaScript Development Environment

Set up Node.js, npm, Git, and VS Code for a reproducible JavaScript workflow, then verify the environment with a small project.

A dependable JavaScript development environment starts with a version-managed Node.js installation, a configured Git identity, and an editor that understands the project. Set those up once, pin the Node version per repository, and verify the whole toolchain with a tiny program before starting a larger application.

What you are building

The basic stack is:

  • Node.js runs JavaScript tools and server-side programs.
  • npm installs dependencies and runs project scripts.
  • Git records changes and connects the project to a remote repository.
  • VS Code provides editing, search, debugging, and an integrated terminal.

This guide uses npm because it ships with Node.js. The same project principles apply if a repository uses pnpm, Yarn, or Bun; do not switch package managers in the middle of a project without updating its lockfile and scripts.

Prerequisites

You need:

  • A terminal: Terminal, PowerShell, bash, or zsh.
  • Permission to install software on your computer.
  • An internet connection.
  • A project folder where you can create files.

Avoid installing project dependencies with administrator privileges. A permission error usually means Node or the package manager was installed in an inconvenient location, not that the project itself should be run as root.

Step 1 — Install Node.js with a version manager

A version manager is preferable to a single system installer because projects can require different Node releases.

macOS and Linux with nvm

Install nvm using the current instructions from the nvm project. The common installer command is:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Restart the terminal so the shell initialization is loaded, then install the long-term-support release:

nvm install --lts
nvm use --lts
node --version
npm --version

Windows with nvm-windows

Install nvm-windows, then use PowerShell:

nvm install lts
nvm use lts
node --version
npm --version

Do not mix nvm-windows with a separate Node installer unless you know which installation owns PATH.

Step 2 — Pin the project Node version

Once you know which Node version the project expects, record it. A simple .nvmrc lets nvm select the version automatically:

22

The exact version belongs to the project, not this tutorial. Check the repository’s engines field, CI workflow, and deployment platform before choosing one. Then run:

nvm use

For teams, also keep the package manager lockfile under version control. package-lock.json, pnpm-lock.yaml, or the equivalent makes a clean install reproducible.

Step 3 — Configure Git

Install Git from git-scm.com or your operating system’s package manager, then set the identity that appears on commits:

git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main

Confirm the values before using them:

git config --global --list

For SSH authentication, follow How to Set Up Git and GitHub from the Command Line. Keep credentials and tokens out of source files and commit history.

Step 4 — Install VS Code

Download VS Code, open the command palette with Cmd/Ctrl + Shift + P, and install the code shell command if your platform offers that action. Then a project opens from the terminal with:

code .

Use How to Set Up VS Code for Web Development for extensions, formatting, debugging, and workspace settings.

Step 5 — Create a project and install dependencies

Create a disposable project to test the complete toolchain:

mkdir hello-js
cd hello-js
npm init -y

Add an index.js file:

const message = "hello devnotes";
console.log(message);

Run it with:

node index.js

When a real project declares dependencies, install them from its manifest:

npm install

Use npm ci in CI and other clean, repeatable environments when the lockfile is present. Use npm install when intentionally changing dependencies and regenerating the lockfile.

Step 6 — Add basic project conventions

A small package.json script makes common actions discoverable:

{
  "scripts": {
    "dev": "node index.js",
    "check": "node --check index.js"
  }
}

Run scripts with:

npm run check
npm run dev

As a project grows, add formatting, linting, tests, and a type checker. Keep configuration in the repository so another developer or CI runner gets the same behavior. For TypeScript-specific setup, continue with How to Set Up a TypeScript Project from Scratch.

Environment variables and secrets

Put non-secret local configuration in a .env file only when the framework supports it, and add that file to .gitignore. Never commit API keys, access tokens, or production credentials. Provide a safe .env.example containing names without values:

API_BASE_URL=http://localhost:3000
API_KEY=

The exact loading mechanism depends on the framework. Check whether the variable belongs in server-only code or can safely be exposed to a browser bundle; a public frontend variable is not a secret merely because it came from .env.

Verify the setup

Before starting a larger project, verify each layer:

node --version
git --version
npm --version
npm run check
git status

A clean git status, a successful Node command, and a successful dependency install confirm that the shell, runtime, package manager, and repository are aligned.

Troubleshooting

  • node: command not found — restart the terminal and check that the version manager’s initialization is loaded before changing PATH manually.
  • The wrong Node version is active — run nvm use, check .nvmrc, and remove competing installer paths only if you understand the system-wide impact.
  • npm install gives permission errors — do not use sudo for project dependencies; fix the Node installation or use a version manager.
  • code is not found — install the shell command from VS Code’s command palette and restart the terminal.
  • Git commits show the wrong name — inspect local and global config with git config --show-origin --list; a repository-local value overrides the global one.
  • A clean install differs from local development — check the lockfile, Node version, package-manager version, and platform-specific optional dependencies.

Next steps

You now have a reproducible baseline for JavaScript work. Configure the editor, create a TypeScript project when static checks help, and automate the checks with GitHub Actions for CI/CD.

Related posts

Comments

One comment per thread every 30 minutes · edits are unlimited.