AceDevHub
Beginner Node.js Interview QuestionsBeginnerConcept

Node.js · Question 17

What is the Node.js REPL?

Direct answer

The REPL (Read-Eval-Print Loop) is an interactive Node shell — type node with no file to experiment with JavaScript, inspect variables with _, and test APIs before adding them to your project.

The REPL is the fastest way to probe Node APIs — crypto output, Buffer encoding, or regex — without creating a temp file. It uses the same V8 engine as running node app.js.

  • Start — node in terminal; .exit or Ctrl+D twice to quit.
  • Special _ variable — holds result of last expression; _ + Enter repeats.
  • Dot commands — .help, .save script.js, .load script.js, .clear context.
  • await in REPL — top-level await supported in modern Node REPL for quick fetch tests.
repl-session.txt
> 2 + 2
4
> const fs = await import('node:fs/promises')
> const pkg = JSON.parse(await fs.readFile('package.json', 'utf8'))
> pkg.name
'@acedevhub/api'
> .exit