Mateen Kiani
Published on Mon Jul 07 2025·3 min read
Creating a Node.js project in VS Code is straightforward. You can scaffold your application, set up scripts, and debug right from your editor. This guide walks you through installing the necessary tools, initializing your project, and configuring VS Code for a smooth development workflow.
By the end, you’ll have a working Node.js app, custom scripts in your package.json
, and a launch profile for debugging—all within VS Code.
Before you begin, make sure you have:
Tip: If you need to update Node.js, see how to update Node.js on Windows.
After installation, open a terminal and verify:
node --versionnpm --version
You should see version numbers for both commands.
Navigate to your workspace folder:
cd path/to/your/projects
Create a new folder and enter it:
mkdir my-node-app && cd my-node-app
Initialize your project:
npm init -y
A package.json
file will appear with defaults. You can edit fields like name
, version
, and description
later.
To boost productivity, add these files to your project root:
.vscode/launch.json
– for debugging..vscode/tasks.json
– for running build or test tasks.{"version": "0.2.0","configurations": [{"type": "node","request": "launch","name": "Debug App","program": "${workspaceFolder}/index.js"}]}
You can start debugging with F5
once this file is in place.
Open package.json
and add a start
script:
"scripts": {"start": "node index.js","dev": "nodemon index.js"}
npm start
will run your app.npm run dev
(with nodemon installed) reloads on file changes.Create index.js
in your project root:
const http = require('http');const PORT = process.env.PORT || 3000;const server = http.createServer((req, res) => {res.statusCode = 200;res.setHeader('Content-Type', 'text/plain');res.end('Hello, Node.js in VS Code!');});server.listen(PORT, () => {console.log(`Server running on http://localhost:${PORT}`);});
If you need extra packages, use npm or Yarn:
npm install express dotenv# ornpm install -g yarn && yarn init
Tip: You can also manage packages with Yarn; see how to install Yarn using npm.
Start the server:
npm start
http://localhost:3000
.Use the Debug panel in VS Code to step through code, inspect variables, and set breakpoints.
.gitignore
file to exclude node_modules/
.“The best way to learn is by doing—build small features, tweak configs, and explore VS Code extensions.”
You’ve set up a basic Node.js project in VS Code, initialized your package.json
, added scripts, and configured debugging. From here, you can add frameworks like Express or NestJS, integrate testing, and automate tasks with GitHub Actions.
Getting your environment right from the start saves time down the road. Now that you know the essentials, experiment with extensions, linters, and deployment options to refine your workflow. Happy coding!