Setting Up Your Backend Environment - Node.js
Setting Up Your Node.js Backend Environment
Last updated: 1/20/2025
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
- Visit the official Node.js website.
- Download the LTS (Long Term Support) version for your operating system.
- 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
- Visit the official VS Code website.
- Download the installer for your operating system and follow the installation instructions.
Install Node.js Extension
- Open VS Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar (or press
Ctrl+Shift+X
/Cmd+Shift+X
). - 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
- Open your terminal and navigate to a folder where you want to create your project.
- Create a new folder and navigate into it:
mkdir my-node-project cd my-node-project
Step 2: Write Your Program
- Open VS Code and create a new file called
hello.js
. - Add the following code:
console.log("Hello, Node.js World!");
Step 3: Run Your Program
- Open your terminal inside VS Code (or use your system terminal).
- 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.