codex-lv4-may-2025

Level Navigation: 1 2 3 (4ℹ️) (5ℹ️) 6 7 8 9 10 11 12 13 14⚡ 15⚡ (16ℹ️) 17 18 19 20 21 22 23 24 25 26⚡ 27⚡ 28⚡ 29 30 31 32 33 34 35 36 37 38 39⚡ 40⚡

Level 5: Kickoff — Start the Server

Practice spinning up an Express app and verifying that you can access it from a client. This level should feel quick—you only need a root route and confidence that the server responds.

Understanding Node.js Runtime and Development Tools

Before starting your server, it’s helpful to understand the tools you’ll use to run your Node.js application:

node vs nodemon

node is the Node.js runtime itself—the program that executes JavaScript files:

nodemon is a development tool that wraps node with automatic restarts:

Example:

# Using node directly (manual restart required)
node src/index.js

# Using nodemon (auto-restart on file changes)
nodemon src/index.js

npm run start vs npm run dev

These are npm scripts defined in your package.json. The difference depends on what each script does:

npm run start (Production/Standard):

npm run dev (Development):

Why have both?

Check your package.json:

{
  "scripts": {
    "start": "node src/index.js",
    "dev": "nodemon src/index.js"
  }
}

Quick Start

  1. Start your server:
    npm run dev
    
  2. Verify it’s running:
    • Look for a message like “Server running on http://localhost:3000”
    • Try accessing http://localhost:3000 in your browser
  3. Test auto-restart (if using dev):
    • Make a small change to your code (e.g., change a message)
    • Save the file
    • Watch the terminal—nodemon should automatically restart the server
  4. Check your root route:
    • Visit http://localhost:3000 in your browser
    • You should see a JSON response or your configured response