Setting Up Node.js in VS Code on Windows 11 [2023] | Step-by-Step Guide

Posted by


In this tutorial, I will guide you through the process of setting up and running Node.js in Visual Studio Code on Windows 11 in 2023. Node.js is a popular runtime environment for running JavaScript applications outside of a browser, and Visual Studio Code is a powerful code editor that provides a wealth of features for developing and debugging Node.js applications.

Before we begin, make sure you have Visual Studio Code installed on your Windows 11 machine. If you don’t have it yet, you can download it from the official website.

Step 1: Install Node.js on Windows 11

The first step is to install Node.js on your Windows 11 machine. To do this, follow these steps:

  1. Open your web browser and go to the Node.js official website at https://nodejs.org/
  2. Download the latest LTS version of Node.js for Windows by clicking on the "Windows Installer" button.
  3. Run the downloaded installer and follow the on-screen instructions to install Node.js on your system.
  4. Once the installation is complete, open a new command prompt or terminal window and type "node -v" to verify that Node.js has been successfully installed. You should see the version number of Node.js displayed.

Step 2: Install the Node.js Extension for Visual Studio Code

Now that you have Node.js installed on your machine, the next step is to install the Node.js extension for Visual Studio Code. This extension provides powerful tools for working with Node.js projects in Visual Studio Code, including IntelliSense, debugging, and npm integration.

To install the Node.js extension, follow these steps:

  1. Open Visual Studio Code on your Windows 11 machine.
  2. Click on the "Extensions" icon in the sidebar or press Ctrl+Shift+X to open the Extensions view.
  3. In the search bar, type "Node.js" and press Enter.
  4. Look for the "Node.js" extension in the search results and click on the "Install" button to install it.
  5. Once the extension is installed, you may need to reload Visual Studio Code to activate it.

Step 3: Create a New Node.js Project in Visual Studio Code

Now that you have Node.js installed and the Node.js extension for Visual Studio Code set up, you can create a new Node.js project in Visual Studio Code. Here’s how to do it:

  1. Open Visual Studio Code and click on the "File" menu at the top of the window.
  2. Select "Open Folder" and choose a location on your machine where you want to create the new Node.js project.
  3. Click on the "New Folder" button to create a new folder for your project and give it a name.
  4. Open the newly created folder in Visual Studio Code by clicking on the "Select Folder" button.
  5. Create a new file in the project folder and name it "app.js". This will be the main JavaScript file for your Node.js application.

Step 4: Write and Run a Simple Node.js Application

Now that you have a new Node.js project set up in Visual Studio Code, you can write a simple Node.js application and run it.

  1. In the "app.js" file, type the following code to create a simple HTTP server that listens on port 3000:
const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, { 'Content-Type': 'text/html' });
  res.end('Hello, Node.js!');
});

server.listen(3000, () => {
  console.log('Server listening on port 3000');
});
  1. Save the file by pressing Ctrl+S or clicking on the "Save" icon in the toolbar.
  2. Open a new terminal window in Visual Studio Code by clicking on the "Terminal" menu and selecting "New Terminal".
  3. Run the Node.js application by typing the following command in the terminal:
node app.js
  1. You should see the message "Server listening on port 3000" printed in the terminal. This means that your Node.js application is running successfully.
  2. Open your web browser and navigate to http://localhost:3000 to see the "Hello, Node.js!" message displayed in the browser.

Congratulations! You have successfully set up and run a Node.js application in Visual Studio Code on Windows 11. This is just the beginning of what you can do with Node.js and Visual Studio Code, so feel free to explore and experiment with different features and functionalities to enhance your Node.js development experience.

0 0 votes
Article Rating
25 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@CSCORNERSunitaRai
2 months ago

Got a question on this topic? Please share through comments or reach us on telegram https://t.me/cscorner

@riggergirl247
2 months ago

God!!! You're a life saver!!! Thank you so much for this tutorial!!!!

@Codingparii
2 months ago

Mm still my problem is not resolved what to do. Mam😓

@sakethchintu6046
2 months ago

Still getting the same error

@a.sharath3106
2 months ago

Thank you so much it worked

@codewithsan23
2 months ago

Go to extension and search node debugger click the below "Javascript debugger" and install it go to the terminal and choose default profile and click it choose javascript debugger there's was two options showed choose Last option and kill the terminal and again open the terminal and execute the program

@Anonymous-dw2in
2 months ago

Thanks 🙂

@crazydauzy8887
2 months ago

your method worked. thank you

@studymania734
2 months ago

Thank you so much

@sunny0791
2 months ago

ive done every step clear but it didnt show any op could you please tell me the solution

@Abhi_0293
2 months ago

TQ SM
🙇‍♂

@syedmujeebandrabi5447
2 months ago

Thanks a lot mam.After several hours of wasting time i found your vide.problem solved .Thankyou mam

@harshalbhondave6520
2 months ago

Thanks for this information ☺️

@deftones8583
2 months ago

what if i dobn't have node.js in path in environment variable

@lovelifestatus2127
2 months ago

Wow mam i have wasted a lot of time other channel
But i got a good channel where we can easily download node js and vs code
Thanku so much mam❤❤❤❤

@JaimeMartinez-oc9ex
2 months ago

THANK YOU 💟💟💟

@DasamulamDaamu
2 months ago

Thankyousm it worked

@Atsumuedit
2 months ago

thanks

@varunbadoni373
2 months ago

THANKYOU SO MUCH 😭😭😭😭😭😭😭😭😭😭😭😭😭😭

@vikramkumar_aditya
2 months ago

Thank you mam………….❣❣