Search⌘ K

Running Node.js and Writing Basic Scripts

Explore how to run Node.js interactively using the REPL and write your first basic JavaScript scripts. This lesson helps you gain hands-on experience executing simple commands, using variables, and running code files in Node.js, laying the foundation for server-side programming.

Node.js is a runtime environment, which means it doesn’t come with a graphical user interface like some other development tools. We interact with Node.js through a command-line interface (CLI). In this lesson, we’ll learn to run Node.js, use its interactive environment (REPL), and create a basic script. Once we’re comfortable with this, we’ll have taken our first steps into server-side JavaScript.

Running Node.js in interactive mode (REPL)

The Node.js REPL lets us interact with JavaScript directly. REPL stands for Read-Eval-Print Loop:

  • Read: It reads the input.

  • Eval: It evaluates the input as JavaScript code. ...