Short JavaScript experiments do not always need a saved script file. The Node.js REPL opens an interactive session where expressions, built-in modules, promises, and small runtime checks can be tried against the same runtime that runs Node.js programs.
The REPL reads one input, evaluates it, prints the result, and keeps the session state available for the next prompt. Values assigned during the session can be reused, and core modules can be loaded while inspecting runtime behavior.
By default, Node.js can save REPL history in .node_repl_history under the user's home directory. Avoid pasting secrets, tokens, or private payloads into a session that may persist history, especially on shared development accounts.
$ node Welcome to Node.js v24.18.0. Type ".help" for more information. >
Use node --interactive when Node.js is launched with piped input or another non-terminal stdin source and the REPL should still open.
> 1 + 1 2
> const label = 'node-repl' undefined
undefined means the declaration completed without returning a separate value. The variable remains available at the next prompt.
> label.toUpperCase() 'NODE-REPL'
> const os = require('node:os')
undefined
> os.platform() 'linux'
The platform string depends on the operating system running Node.js, so darwin or win32 can appear on macOS or Windows.
> await Promise.resolve('ready')
'ready'
> .help .break Sometimes you get stuck, this gets you out .clear Alias for .break .exit Exit the REPL .help Print this help message .load Load JS from a file into the REPL session .save Save all evaluated commands in this REPL session to a file Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL
> .exit $