惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
有赞技术团队
有赞技术团队
博客园 - 三生石上(FineUI控件)
博客园_首页
博客园 - 【当耐特】
WordPress大学
WordPress大学
月光博客
月光博客
博客园 - 叶小钗
S
SegmentFault 最新的问题
雷峰网
雷峰网
H
Help Net Security
宝玉的分享
宝玉的分享
A
About on SuperTechFans
IT之家
IT之家
J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
B
Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Y
Y Combinator Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Setting Up Your First Node.js Application Step-by-Step
Ritam Saha · 2026-05-02 · via DEV Community

Introduction

Imagine you're a developer staring at a blank screen, buzzing with ideas for your dream web app, but you're stuck at basic square one—no runtime, no environment, no idea where to start how to do. Sound familiar? But not anymore...

Node.js changes everything for us. What seemed impossible one day, but NodeJS says "not anymore broo". Node is the powerhouse JavaScript runtime that lets you run JS on the server side, powering giants like Netflix and LinkedIn. Whether you're a CS student building your portfolio or a hobbyist dipping into full-stack dev, this guide walks you through every step to build your first Node.js app. No frameworks—just pure, hands-on setup. By the end, you'll have a "Hello World" server humming on your machine. Let's dive in.


Installing NodeJS: Setup with Platform Notes

NodeJS installation is straightforward and consistent across operating systems. The golden rule? Use the official NodeSource binaries or your system's package manager for the latest LTS (Long-Term Support) version. This ensures stability for production-like projects.

Step 1: Download from the Official Site (Universal Starting Point)

Head to nodejs.org. Grab the LTS version:

  • Windows: Download the .msi installer. Run it as administrator mode in powershell, follow the wizard (enable "Add to PATH" checkbox), and restart your terminal.
  • macOS: Get the .pkg installer. Double-click, enter your password, and let it install. Homebrew users: brew install node.
  • Linux (Ubuntu/Debian): Use NodeSource repo for freshness:
  curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
  sudo apt-get install -ca nodejs

Enter fullscreen mode Exit fullscreen mode

  • Linux (Fedora/RHEL): sudo dnf install nodejs (or use NodeSource similarly).
  • NixOS or Nix Environments: Add to configuration.nix:
  environment.systemPackages = with pkgs; [ nodejs ];

Enter fullscreen mode Exit fullscreen mode

Then sudo nixos-rebuild switch.

Pro tip: Avoid downloading from third-party sites to dodge malware. Installation takes 2-5 minutes max.

Node Installation


Verifying Your Installation

Fire up your terminal (Command Prompt/PowerShell on Windows, Terminal on macOS/Linux/NixOS). Type:

node --version
npm --version

Enter fullscreen mode Exit fullscreen mode

You should see something like v24.14.0 for node, not exactly this, I mean in this structure. And for npm you might see like 11.9.0. npm gets download automatically with node, npm is nothing but node package manager (though if you go to npm's official site, they call it as npm package manager), this is for to install any other packages/dependancies that will help building your site and it comes with node's download by default.

node version check

Node is live. This command confirms the runtime is ready to execute JavaScript outside the browser.


Demystifying the Node.js REPL: Your Interactive Playground

Before we code, let's unpack REPL. REPL stands for Read-Eval-Print Loop—Node's built-in interactive shell for testing code snippets on the fly. It's like a JavaScript console in your terminal: type code, hit Enter, see results instantly. Perfect for experimenting without files.

Launch it:

node

Enter fullscreen mode Exit fullscreen mode

Your prompt changes to >. Try:

> console.log('Hello, Node!')
> 2 + 2
> let x = 5; x * 3

Enter fullscreen mode Exit fullscreen mode

Exit with Ctrl+C twice or .exit.

REPL

REPL shines for quick prototypes—think debugging math logic or testing string methods before building full scripts.


Creating and Running Your First JavaScript File

Time to level up from REPL. Create a project folder:

mkdir my-first-node-app
cd my-first-node-app

Enter fullscreen mode Exit fullscreen mode

Use your editor (VS Code recommended code . in addressbar, if installed). Make hello.js (touch hello.js in terminal):

console.log('Hello from my first Node.js script!');
console.log('Node version:', process.version);

Enter fullscreen mode Exit fullscreen mode

Save it. Run with:

node hello.js

Enter fullscreen mode Exit fullscreen mode

First execution output (yours should match):

Hello from my first Node.js script!
Node version: v20.12.2

Enter fullscreen mode Exit fullscreen mode

Magic! Node reads the file, compiles it just-in-time, executes in the V8 engine (Chrome's JS heart), and prints to stdout. No browser needed.


Building a Hello World Server: Your First Server

NodeJS excels at servers via its http module (built-in, no npm needed). Create server.js:

const http = require('node:http'); //CommonJS type

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World from Node.js Server!\n');
});

const port = 3000;
server.listen(port, 'localhost', () => {
  console.log(`Server running at http://localhost:${port}/`);
});

Enter fullscreen mode Exit fullscreen mode

Run it:

node server.js

Enter fullscreen mode Exit fullscreen mode

Output: Server running at http://localhost:3000/. Open that URL in your browser, "Hello World from Node.js Server!" greets you.

Stop with Ctrl+C. This introduces Node's event-driven model: the server loops, handling requests non-blockingly.


Wrapping Up: From Zero to Node Hero

You've just conquered Node.js setup—from install to a live server—without frameworks clouding the waters. This foundation unlocks full-stack magic: pair it with Express later, deploy to Vercel (my go-to for portfolio projects), and watch your GitHub shine. As a third-year CS student juggling Java backends and Node experiments, I live this daily—it's empowering.

What's your first project idea? Drop it in the comments!