Express.js Mastery / Introduction To Node.js And NPM

Running Javascript Outside the Browser

๐Ÿ› ๏ธ Prerequisites

  • โœ… Node.js must be installed on your computer before starting.


๐Ÿ“‚ Step 1: Set Up the Project Folder

  1. Copy the Complete Node Bootcamp folder from the course starter files into your working directory.
    e.g., Desktop/complete-node-bootcamp/

  2. If you haven't downloaded the starter files yet, get them from the course's GitHub repository.

    ๐Ÿ”— https://github.com/codevedadev/complete-node-bootcamp

  3. ๐Ÿ’ป Open the folder in your code editor (VS Code is used here, but any editor works).

  4. Open VS Code Terminal
    Shortcut: Ctrl + ```(Backtick key) OR Click Terminal -> New Terminal

๐Ÿ’กNote: In this section, you won't work on the actual project yet. You'll first practice using Node.js from the command line.


๐Ÿš€ Step 2: Start the Node REPL

  • Type: node

  • Then press Enter.

  • ๐ŸŸข This opens the Node REPL (Read-Eval-Print Loop).

  • ๐Ÿ’ป It's an interactive environment where you can write and execute JavaScript instantly, similar to a browser's Developer Console.


โœ๏ธ Step 3: Write JavaScript in the REPL

You can define variables:

const name = "Jonas";
  • โœ… Run any valid JavaScript code.

  • โšก Node.js supports modern JavaScript (ES6+) features like const, let, arrow functions, template literals, and more.

  • ๐ŸŒ Unlike browsers, Node.js executes JavaScript directly on your computer.

๐Ÿงฎ Example

3 * 8
// Output: 24

โŒจ๏ธ Useful REPL Shortcuts

โŒจ๏ธ Action

โœ… How To Do It

๐Ÿšช Exit the REPL

Type .exit and press Enter

๐Ÿšช Exit (Alternative)

Press Ctrl + D

๐Ÿงน Clear Terminal

Ctrl + K (Windows) / Cmd + K (Mac)

๐ŸŒ Show Global Variables

Press Tab (sometimes twice)

๐Ÿ” Show Object Methods

Type ObjectName. then press Tab (e.g., String. + Tab)


๐ŸŒ Explore Global Variables

If you are in REPL Mode then Press Tab twice without typing anything.

OR Else

Type node then Enter and then Tab twice

You'll see globally available objects such as:

  • ๐Ÿ“ฆ Array

  • ๐Ÿ”ค String

  • โž• Math

  • ๐Ÿ”ข Number

You'll also notice Node.js-specific modules like:

  • ๐ŸŒ https

  • ๐Ÿ“‚ fs

  • ๐Ÿ” crypto

๐Ÿ’ก These built-in modules will be covered later in the course.


๐ŸŽฏ The Underscore (_) Trick

The underscore (_) automatically stores the result of the last executed expression.

Example

3 * 8
// Output: 24

_ + 6
// Output: 30

_ - 30
// Output: 0

๐Ÿ’ก This is useful for quick calculations without retyping previous results.


๐Ÿšช Exit Properly

  • ๐Ÿ‘‹ Exit the REPL:

    • Ctrl + D

    • or type .exit


๐ŸŽฏ Key Takeaways

  • ๐ŸŸข Node.js allows JavaScript to run outside the browser.

  • ๐Ÿ’ป The REPL is an interactive environment for testing JavaScript code quickly.

  • โšก It supports modern JavaScript (ES6+) features out of the box.

  • ๐Ÿงช Use the REPL to experiment with JavaScript before writing full programs.

  • ๐Ÿงญ The Tab key helps discover global objects and built-in methods.

  • ๐ŸŽฏ The underscore (_) stores the last evaluated result, making quick calculations easier.