Setting Up Your Backend Environment - Node.js

Setting Up Your Node.js Backend Environment

Last updated: 1/20/2025

1 hour
Medium

Setting Up Your Node.js Backend Environment

In this lesson, we’ll guide you through setting up a Node.js-based backend development environment. By the end, you’ll have all the tools needed to run a simple Node.js program.


1. Install Node.js

Download and Install Node.js

  1. Visit the official Node.js website.
  2. Download the LTS (Long Term Support) version for your operating system.
  3. Follow the installation instructions for your system.

Verify Installation

Open your terminal and run:

node --version

This will display the installed Node.js version.

You should also verify that npm (Node Package Manager) is installed:

npm --version

Both Node.js and npm should now be ready to use.


2. Install Visual Studio Code

Visual Studio Code (VS Code) is a lightweight and powerful code editor, perfect for Node.js development.

Download and Install VS Code

  1. Visit the official VS Code website.
  2. Download the installer for your operating system and follow the installation instructions.

Install Node.js Extension

  1. Open VS Code.
  2. Go to the Extensions view by clicking on the Extensions icon in the Activity Bar (or press Ctrl+Shift+X / Cmd+Shift+X).
  3. Search for "JavaScript and TypeScript Nightly" and install the extension.

3. Create a Simple Node.js Program

Let’s create a simple program to ensure your environment is working correctly.

Step 1: Create a Project Folder

  1. Open your terminal and navigate to a folder where you want to create your project.
  2. Create a new folder and navigate into it:
    mkdir my-node-project cd my-node-project

Step 2: Write Your Program

  1. Open VS Code and create a new file called hello.js.
  2. Add the following code:
    console.log("Hello, Node.js World!");

Step 3: Run Your Program

  1. Open your terminal inside VS Code (or use your system terminal).
  2. Run the program:
    node hello.js

You should see the output:

Hello, Node.js World!

What’s Next?

With your Node.js environment set up and working, you’re ready to start exploring more advanced topics. In the next lessons, we’ll dive into creating simple servers, routing, and building APIs using Node.js.