Developing Node.js with VS Code
Visual Studio Code (VS Code for short) is a free, open-source code editor developed by Microsoft, and is currently one of the most popular editors for Node.js development.
Main advantages
- Built-in Node.js support: Provides intelligent code completion, debugging, and other features
- Rich extensions: Various Node.js development tools can be installed through the extension marketplace
- Integrated terminal: Run Node.js programs directly in the editor
- Lightweight and fast: Fast startup and low resource usage
Install VS Code
- Access the VS Code official website
- Download the version for your operating system
- Follow the installation wizard to complete the installation
- Complete VS Code tutorial:https://www.runoob.com/vscode/vscode-tutorial.html
In addition, domestic companies Alibaba and ByteDance also have AI IDEs developed based on VS Code:
Alibaba Qoder
An AI programming IDE launched by Alibaba, deeply customized based on VS Code
Visit ->
ByteDance Trae
A new-generation AI-native development environment launched by ByteDance
Visit ->
Recommended extensions
- Node.js Extension Pack: A collection package containing multiple Node.js-related plugins
- JavaScript (ES6) code snippets: Provides ES6+ code snippets
- Auto Rename Tag: Automatically renames HTML/XML tags
- ESLint: Code quality checking tool
- Prettier: Code formatting tool
- npm Intellisense: npm package auto-completion
- Path Intellisense: File path auto-completion
Create your first Node.js project
Initialize a project
- Open the terminal (press Ctrl+` in VS Code)
- Create a project folder and enter it:
mkdir my-node-app
cd my-node-app
-
Initialize the npm project:
npm init -y
This will produce a package.json file:

Create the main file
- Create in VS Code
app.js file
- Enter the following code:
Example
const http = require('http');
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end(' RUNOOB Node Test ~ Hello, Node.js!\n');
});
const port = 3000;
server.listen(port, () => {
console.log(`Server running at: http://localhost:${port}/`);
});
Run the Project
- Execute in the terminal:
node app.js

- Open the browser and visit
http://localhost:3000

Please note that when we type console., VS Code's IntelliSense can provide code suggestions:

Debug Node.js applications
VS Code provides powerful debugging features:
Configure debugging
- Click the "Run and Debug" icon in the left activity bar
- Click "Create a launch.json file"
- Select the "Node.js" environment

Set breakpoints
- Click to the left of the line number to set a breakpoint
- Press F5 to start debugging
- Use the debug toolbar to control the execution flow
Debug controls
- Continue (F5): Continue executing to the next breakpoint
- Step Over (F10): Execute the current line without entering the function
- Step Into (F11): Enter the function
- Restart (Ctrl+Shift+F5): Restart debugging
- Stop (Shift+F5): End debugging