{ "type": "module", "source": "doc/api/repl.md", "modules": [ { "textRaw": "REPL", "name": "repl", "introduced_in": "v0.10.0", "stability": 2, "stabilityText": "Stable", "desc": "

Source Code: lib/repl.js

\n

The repl module provides a Read-Eval-Print-Loop (REPL) implementation that\nis available both as a standalone program or includible in other applications.\nIt can be accessed using:

\n
const repl = require('repl');\n
", "modules": [ { "textRaw": "Design and features", "name": "design_and_features", "desc": "

The repl module exports the repl.REPLServer class. While running,\ninstances of repl.REPLServer will accept individual lines of user input,\nevaluate those according to a user-defined evaluation function, then output the\nresult. Input and output may be from stdin and stdout, respectively, or may\nbe connected to any Node.js stream.

\n

Instances of repl.REPLServer support automatic completion of inputs,\ncompletion preview, simplistic Emacs-style line editing, multi-line inputs,\nZSH-like reverse-i-search, ZSH-like substring-based history search,\nANSI-styled output, saving and restoring current REPL session state, error\nrecovery, and customizable evaluation functions. Terminals that do not support\nANSI styles and Emacs-style line editing automatically fall back to a limited\nfeature set.

", "modules": [ { "textRaw": "Commands and special keys", "name": "commands_and_special_keys", "desc": "

The following special commands are supported by all REPL instances:

\n\n
> .editor\n// Entering editor mode (^D to finish, ^C to cancel)\nfunction welcome(name) {\n  return `Hello ${name}!`;\n}\n\nwelcome('Node.js User');\n\n// ^D\n'Hello Node.js User!'\n>\n
\n

The following key combinations in the REPL have these special effects:

\n\n

For key bindings related to the reverse-i-search, see reverse-i-search.\nFor all other key bindings, see TTY keybindings.

", "type": "module", "displayName": "Commands and special keys" }, { "textRaw": "Default evaluation", "name": "default_evaluation", "desc": "

By default, all instances of repl.REPLServer use an evaluation function\nthat evaluates JavaScript expressions and provides access to Node.js built-in\nmodules. This default behavior can be overridden by passing in an alternative\nevaluation function when the repl.REPLServer instance is created.

", "modules": [ { "textRaw": "JavaScript expressions", "name": "javascript_expressions", "desc": "

The default evaluator supports direct evaluation of JavaScript expressions:

\n
> 1 + 1\n2\n> const m = 2\nundefined\n> m + 1\n3\n
\n

Unless otherwise scoped within blocks or functions, variables declared\neither implicitly or using the const, let, or var keywords\nare declared at the global scope.

", "type": "module", "displayName": "JavaScript expressions" }, { "textRaw": "Global and local scope", "name": "global_and_local_scope", "desc": "

The default evaluator provides access to any variables that exist in the global\nscope. It is possible to expose a variable to the REPL explicitly by assigning\nit to the context object associated with each REPLServer:

\n
const repl = require('repl');\nconst msg = 'message';\n\nrepl.start('> ').context.m = msg;\n
\n

Properties in the context object appear as local within the REPL:

\n
$ node repl_test.js\n> m\n'message'\n
\n

Context properties are not read-only by default. To specify read-only globals,\ncontext properties must be defined using Object.defineProperty():

\n
const repl = require('repl');\nconst msg = 'message';\n\nconst r = repl.start('> ');\nObject.defineProperty(r.context, 'm', {\n  configurable: false,\n  enumerable: true,\n  value: msg\n});\n
", "type": "module", "displayName": "Global and local scope" }, { "textRaw": "Accessing core Node.js modules", "name": "accessing_core_node.js_modules", "desc": "

The default evaluator will automatically load Node.js core modules into the\nREPL environment when used. For instance, unless otherwise declared as a\nglobal or scoped variable, the input fs will be evaluated on-demand as\nglobal.fs = require('fs').

\n
> fs.createReadStream('./some/file');\n
", "type": "module", "displayName": "Accessing core Node.js modules" }, { "textRaw": "Global uncaught exceptions", "name": "global_uncaught_exceptions", "meta": { "changes": [ { "version": "v12.3.0", "pr-url": "https://github.com/nodejs/node/pull/27151", "description": "The `'uncaughtException'` event is from now on triggered if the repl is used as standalone program." } ] }, "desc": "

The REPL uses the domain module to catch all uncaught exceptions for that\nREPL session.

\n

This use of the domain module in the REPL has these side effects:

\n\n

As standalone program:

\n
process.on('uncaughtException', () => console.log('Uncaught'));\n\nthrow new Error('foobar');\n// Uncaught\n
\n

When used in another application:

\n
process.on('uncaughtException', () => console.log('Uncaught'));\n// TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException`\n// cannot be used in the REPL\n\nthrow new Error('foobar');\n// Thrown:\n// Error: foobar\n
", "type": "module", "displayName": "Global uncaught exceptions" }, { "textRaw": "Assignment of the `_` (underscore) variable", "name": "assignment_of_the_`_`_(underscore)_variable", "meta": { "changes": [ { "version": "v9.8.0", "pr-url": "https://github.com/nodejs/node/pull/18919", "description": "Added `_error` support." } ] }, "desc": "

The default evaluator will, by default, assign the result of the most recently\nevaluated expression to the special variable _ (underscore).\nExplicitly setting _ to a value will disable this behavior.

\n
> [ 'a', 'b', 'c' ]\n[ 'a', 'b', 'c' ]\n> _.length\n3\n> _ += 1\nExpression assignment to _ now disabled.\n4\n> 1 + 1\n2\n> _\n4\n
\n

Similarly, _error will refer to the last seen error, if there was any.\nExplicitly setting _error to a value will disable this behavior.

\n
> throw new Error('foo');\nError: foo\n> _error.message\n'foo'\n
", "type": "module", "displayName": "Assignment of the `_` (underscore) variable" }, { "textRaw": "`await` keyword", "name": "`await`_keyword", "desc": "

With the --experimental-repl-await command line option specified,\nexperimental support for the await keyword is enabled.

\n
> await Promise.resolve(123)\n123\n> await Promise.reject(new Error('REPL await'))\nError: REPL await\n    at repl:1:45\n> const timeout = util.promisify(setTimeout);\nundefined\n> const old = Date.now(); await timeout(1000); console.log(Date.now() - old);\n1002\nundefined\n
", "type": "module", "displayName": "`await` keyword" } ], "type": "module", "displayName": "Default evaluation" }, { "textRaw": "Reverse-i-search", "name": "reverse-i-search", "meta": { "added": [ "v13.6.0" ], "changes": [] }, "desc": "

The REPL supports bi-directional reverse-i-search similar to ZSH. It is\ntriggered with <ctrl> + R to search backwards and <ctrl> + S to search\nforwards.

\n

Duplicated history entires will be skipped.

\n

Entries are accepted as soon as any button is pressed that doesn't correspond\nwith the reverse search. Cancelling is possible by pressing escape or\n<ctrl> + C.

\n

Changing the direction immediately searches for the next entry in the expected\ndirection from the current position on.

", "type": "module", "displayName": "Reverse-i-search" }, { "textRaw": "Custom evaluation functions", "name": "custom_evaluation_functions", "desc": "

When a new repl.REPLServer is created, a custom evaluation function may be\nprovided. This can be used, for instance, to implement fully customized REPL\napplications.

\n

The following illustrates a hypothetical example of a REPL that performs\ntranslation of text from one language to another:

\n
const repl = require('repl');\nconst { Translator } = require('translator');\n\nconst myTranslator = new Translator('en', 'fr');\n\nfunction myEval(cmd, context, filename, callback) {\n  callback(null, myTranslator.translate(cmd));\n}\n\nrepl.start({ prompt: '> ', eval: myEval });\n
", "modules": [ { "textRaw": "Recoverable errors", "name": "recoverable_errors", "desc": "

As a user is typing input into the REPL prompt, pressing the <enter> key will\nsend the current line of input to the eval function. In order to support\nmulti-line input, the eval function can return an instance of repl.Recoverable\nto the provided callback function:

\n
function myEval(cmd, context, filename, callback) {\n  let result;\n  try {\n    result = vm.runInThisContext(cmd);\n  } catch (e) {\n    if (isRecoverableError(e)) {\n      return callback(new repl.Recoverable(e));\n    }\n  }\n  callback(null, result);\n}\n\nfunction isRecoverableError(error) {\n  if (error.name === 'SyntaxError') {\n    return /^(Unexpected end of input|Unexpected token)/.test(error.message);\n  }\n  return false;\n}\n
", "type": "module", "displayName": "Recoverable errors" } ], "type": "module", "displayName": "Custom evaluation functions" }, { "textRaw": "Customizing REPL output", "name": "customizing_repl_output", "desc": "

By default, repl.REPLServer instances format output using the\nutil.inspect() method before writing the output to the provided Writable\nstream (process.stdout by default). The showProxy inspection option is set\nto true by default and the colors option is set to true depending on the\nREPL's useColors option.

\n

The useColors boolean option can be specified at construction to instruct the\ndefault writer to use ANSI style codes to colorize the output from the\nutil.inspect() method.

\n

If the REPL is run as standalone program, it is also possible to change the\nREPL's inspection defaults from inside the REPL by using the\ninspect.replDefaults property which mirrors the defaultOptions from\nutil.inspect().

\n
> util.inspect.replDefaults.compact = false;\nfalse\n> [1]\n[\n  1\n]\n>\n
\n

To fully customize the output of a repl.REPLServer instance pass in a new\nfunction for the writer option on construction. The following example, for\ninstance, simply converts any input text to upper case:

\n
const repl = require('repl');\n\nconst r = repl.start({ prompt: '> ', eval: myEval, writer: myWriter });\n\nfunction myEval(cmd, context, filename, callback) {\n  callback(null, cmd);\n}\n\nfunction myWriter(output) {\n  return output.toUpperCase();\n}\n
", "type": "module", "displayName": "Customizing REPL output" } ], "type": "module", "displayName": "Design and features" }, { "textRaw": "The Node.js REPL", "name": "the_node.js_repl", "desc": "

Node.js itself uses the repl module to provide its own interactive interface\nfor executing JavaScript. This can be used by executing the Node.js binary\nwithout passing any arguments (or by passing the -i argument):

\n
$ node\n> const a = [1, 2, 3];\nundefined\n> a\n[ 1, 2, 3 ]\n> a.forEach((v) => {\n...   console.log(v);\n...   });\n1\n2\n3\n
", "modules": [ { "textRaw": "Environment variable options", "name": "environment_variable_options", "desc": "

Various behaviors of the Node.js REPL can be customized using the following\nenvironment variables:

\n", "type": "module", "displayName": "Environment variable options" }, { "textRaw": "Persistent history", "name": "persistent_history", "desc": "

By default, the Node.js REPL will persist history between node REPL sessions\nby saving inputs to a .node_repl_history file located in the user's home\ndirectory. This can be disabled by setting the environment variable\nNODE_REPL_HISTORY=''.

", "type": "module", "displayName": "Persistent history" }, { "textRaw": "Using the Node.js REPL with advanced line-editors", "name": "using_the_node.js_repl_with_advanced_line-editors", "desc": "

For advanced line-editors, start Node.js with the environment variable\nNODE_NO_READLINE=1. This will start the main and debugger REPL in canonical\nterminal settings, which will allow use with rlwrap.

\n

For example, the following can be added to a .bashrc file:

\n
alias node=\"env NODE_NO_READLINE=1 rlwrap node\"\n
", "type": "module", "displayName": "Using the Node.js REPL with advanced line-editors" }, { "textRaw": "Starting multiple REPL instances against a single running instance", "name": "starting_multiple_repl_instances_against_a_single_running_instance", "desc": "

It is possible to create and run multiple REPL instances against a single\nrunning instance of Node.js that share a single global object but have\nseparate I/O interfaces.

\n

The following example, for instance, provides separate REPLs on stdin, a Unix\nsocket, and a TCP socket:

\n
const net = require('net');\nconst repl = require('repl');\nlet connections = 0;\n\nrepl.start({\n  prompt: 'Node.js via stdin> ',\n  input: process.stdin,\n  output: process.stdout\n});\n\nnet.createServer((socket) => {\n  connections += 1;\n  repl.start({\n    prompt: 'Node.js via Unix socket> ',\n    input: socket,\n    output: socket\n  }).on('exit', () => {\n    socket.end();\n  });\n}).listen('/tmp/node-repl-sock');\n\nnet.createServer((socket) => {\n  connections += 1;\n  repl.start({\n    prompt: 'Node.js via TCP socket> ',\n    input: socket,\n    output: socket\n  }).on('exit', () => {\n    socket.end();\n  });\n}).listen(5001);\n
\n

Running this application from the command line will start a REPL on stdin.\nOther REPL clients may connect through the Unix socket or TCP socket. telnet,\nfor instance, is useful for connecting to TCP sockets, while socat can be used\nto connect to both Unix and TCP sockets.

\n

By starting a REPL from a Unix socket-based server instead of stdin, it is\npossible to connect to a long-running Node.js process without restarting it.

\n

For an example of running a \"full-featured\" (terminal) REPL over\na net.Server and net.Socket instance, see:\nhttps://gist.github.com/TooTallNate/2209310.

\n

For an example of running a REPL instance over curl(1), see:\nhttps://gist.github.com/TooTallNate/2053342.

", "type": "module", "displayName": "Starting multiple REPL instances against a single running instance" } ], "type": "module", "displayName": "The Node.js REPL" } ], "classes": [ { "textRaw": "Class: `REPLServer`", "type": "class", "name": "REPLServer", "meta": { "added": [ "v0.1.91" ], "changes": [] }, "desc": "\n

Instances of repl.REPLServer are created using the repl.start() method\nor directly using the JavaScript new keyword.

\n
const repl = require('repl');\n\nconst options = { useColors: true };\n\nconst firstInstance = repl.start(options);\nconst secondInstance = new repl.REPLServer(options);\n
", "events": [ { "textRaw": "Event: `'exit'`", "type": "event", "name": "exit", "meta": { "added": [ "v0.7.7" ], "changes": [] }, "params": [], "desc": "

The 'exit' event is emitted when the REPL is exited either by receiving the\n.exit command as input, the user pressing <ctrl>-C twice to signal SIGINT,\nor by pressing <ctrl>-D to signal 'end' on the input stream. The listener\ncallback is invoked without any arguments.

\n
replServer.on('exit', () => {\n  console.log('Received \"exit\" event from repl!');\n  process.exit();\n});\n
" }, { "textRaw": "Event: `'reset'`", "type": "event", "name": "reset", "meta": { "added": [ "v0.11.0" ], "changes": [] }, "params": [], "desc": "

The 'reset' event is emitted when the REPL's context is reset. This occurs\nwhenever the .clear command is received as input unless the REPL is using\nthe default evaluator and the repl.REPLServer instance was created with the\nuseGlobal option set to true. The listener callback will be called with a\nreference to the context object as the only argument.

\n

This can be used primarily to re-initialize REPL context to some pre-defined\nstate:

\n
const repl = require('repl');\n\nfunction initializeContext(context) {\n  context.m = 'test';\n}\n\nconst r = repl.start({ prompt: '> ' });\ninitializeContext(r.context);\n\nr.on('reset', initializeContext);\n
\n

When this code is executed, the global 'm' variable can be modified but then\nreset to its initial value using the .clear command:

\n
$ ./node example.js\n> m\n'test'\n> m = 1\n1\n> m\n1\n> .clear\nClearing context...\n> m\n'test'\n>\n
" } ], "methods": [ { "textRaw": "`replServer.defineCommand(keyword, cmd)`", "type": "method", "name": "defineCommand", "meta": { "added": [ "v0.3.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`keyword` {string} The command keyword (*without* a leading `.` character).", "name": "keyword", "type": "string", "desc": "The command keyword (*without* a leading `.` character)." }, { "textRaw": "`cmd` {Object|Function} The function to invoke when the command is processed.", "name": "cmd", "type": "Object|Function", "desc": "The function to invoke when the command is processed." } ] } ], "desc": "

The replServer.defineCommand() method is used to add new .-prefixed commands\nto the REPL instance. Such commands are invoked by typing a . followed by the\nkeyword. The cmd is either a Function or an Object with the following\nproperties:

\n\n

The following example shows two new commands added to the REPL instance:

\n
const repl = require('repl');\n\nconst replServer = repl.start({ prompt: '> ' });\nreplServer.defineCommand('sayhello', {\n  help: 'Say hello',\n  action(name) {\n    this.clearBufferedCommand();\n    console.log(`Hello, ${name}!`);\n    this.displayPrompt();\n  }\n});\nreplServer.defineCommand('saybye', function saybye() {\n  console.log('Goodbye!');\n  this.close();\n});\n
\n

The new commands can then be used from within the REPL instance:

\n
> .sayhello Node.js User\nHello, Node.js User!\n> .saybye\nGoodbye!\n
" }, { "textRaw": "`replServer.displayPrompt([preserveCursor])`", "type": "method", "name": "displayPrompt", "meta": { "added": [ "v0.1.91" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`preserveCursor` {boolean}", "name": "preserveCursor", "type": "boolean" } ] } ], "desc": "

The replServer.displayPrompt() method readies the REPL instance for input\nfrom the user, printing the configured prompt to a new line in the output\nand resuming the input to accept new input.

\n

When multi-line input is being entered, an ellipsis is printed rather than the\n'prompt'.

\n

When preserveCursor is true, the cursor placement will not be reset to 0.

\n

The replServer.displayPrompt method is primarily intended to be called from\nwithin the action function for commands registered using the\nreplServer.defineCommand() method.

" }, { "textRaw": "`replServer.clearBufferedCommand()`", "type": "method", "name": "clearBufferedCommand", "meta": { "added": [ "v9.0.0" ], "changes": [] }, "signatures": [ { "params": [] } ], "desc": "

The replServer.clearBufferedCommand() method clears any command that has been\nbuffered but not yet executed. This method is primarily intended to be\ncalled from within the action function for commands registered using the\nreplServer.defineCommand() method.

" }, { "textRaw": "`replServer.parseREPLKeyword(keyword[, rest])`", "type": "method", "name": "parseREPLKeyword", "meta": { "added": [ "v0.8.9" ], "deprecated": [ "v9.0.0" ], "changes": [] }, "stability": 0, "stabilityText": "Deprecated.", "signatures": [ { "return": { "textRaw": "Returns: {boolean}", "name": "return", "type": "boolean" }, "params": [ { "textRaw": "`keyword` {string} the potential keyword to parse and execute", "name": "keyword", "type": "string", "desc": "the potential keyword to parse and execute" }, { "textRaw": "`rest` {any} any parameters to the keyword command", "name": "rest", "type": "any", "desc": "any parameters to the keyword command" } ] } ], "desc": "

An internal method used to parse and execute REPLServer keywords.\nReturns true if keyword is a valid keyword, otherwise false.

" }, { "textRaw": "`replServer.setupHistory(historyPath, callback)`", "type": "method", "name": "setupHistory", "meta": { "added": [ "v11.10.0" ], "changes": [] }, "signatures": [ { "params": [ { "textRaw": "`historyPath` {string} the path to the history file", "name": "historyPath", "type": "string", "desc": "the path to the history file" }, { "textRaw": "`callback` {Function} called when history writes are ready or upon error", "name": "callback", "type": "Function", "desc": "called when history writes are ready or upon error", "options": [ { "textRaw": "`err` {Error}", "name": "err", "type": "Error" }, { "textRaw": "`repl` {repl.REPLServer}", "name": "repl", "type": "repl.REPLServer" } ] } ] } ], "desc": "

Initializes a history log file for the REPL instance. When executing the\nNode.js binary and using the command line REPL, a history file is initialized\nby default. However, this is not the case when creating a REPL\nprogrammatically. Use this method to initialize a history log file when working\nwith REPL instances programmatically.

" } ] } ], "properties": [ { "textRaw": "`builtinModules` {string[]}", "type": "string[]", "name": "builtinModules", "meta": { "added": [ "v14.5.0" ], "changes": [] }, "desc": "

A list of the names of all Node.js modules, e.g., 'http'.

" } ], "methods": [ { "textRaw": "`repl.start([options])`", "type": "method", "name": "start", "meta": { "added": [ "v0.1.91" ], "changes": [ { "version": "v13.4.0", "pr-url": "https://github.com/nodejs/node/pull/30811", "description": "The `preview` option is now available." }, { "version": "v12.0.0", "pr-url": "https://github.com/nodejs/node/pull/26518", "description": "The `terminal` option now follows the default description in all cases and `useColors` checks `hasColors()` if available." }, { "version": "v10.0.0", "pr-url": "https://github.com/nodejs/node/pull/19187", "description": "The `REPL_MAGIC_MODE` `replMode` was removed." }, { "version": "v5.8.0", "pr-url": "https://github.com/nodejs/node/pull/5388", "description": "The `options` parameter is optional now." } ] }, "signatures": [ { "return": { "textRaw": "Returns: {repl.REPLServer}", "name": "return", "type": "repl.REPLServer" }, "params": [ { "textRaw": "`options` {Object|string}", "name": "options", "type": "Object|string", "options": [ { "textRaw": "`prompt` {string} The input prompt to display. **Default:** `'> '` (with a trailing space).", "name": "prompt", "type": "string", "default": "`'> '` (with a trailing space)", "desc": "The input prompt to display." }, { "textRaw": "`input` {stream.Readable} The `Readable` stream from which REPL input will be read. **Default:** `process.stdin`.", "name": "input", "type": "stream.Readable", "default": "`process.stdin`", "desc": "The `Readable` stream from which REPL input will be read." }, { "textRaw": "`output` {stream.Writable} The `Writable` stream to which REPL output will be written. **Default:** `process.stdout`.", "name": "output", "type": "stream.Writable", "default": "`process.stdout`", "desc": "The `Writable` stream to which REPL output will be written." }, { "textRaw": "`terminal` {boolean} If `true`, specifies that the `output` should be treated as a TTY terminal. **Default:** checking the value of the `isTTY` property on the `output` stream upon instantiation.", "name": "terminal", "type": "boolean", "default": "checking the value of the `isTTY` property on the `output` stream upon instantiation", "desc": "If `true`, specifies that the `output` should be treated as a TTY terminal." }, { "textRaw": "`eval` {Function} The function to be used when evaluating each given line of input. **Default:** an async wrapper for the JavaScript `eval()` function. An `eval` function can error with `repl.Recoverable` to indicate the input was incomplete and prompt for additional lines.", "name": "eval", "type": "Function", "default": "an async wrapper for the JavaScript `eval()` function. An `eval` function can error with `repl.Recoverable` to indicate the input was incomplete and prompt for additional lines", "desc": "The function to be used when evaluating each given line of input." }, { "textRaw": "`useColors` {boolean} If `true`, specifies that the default `writer` function should include ANSI color styling to REPL output. If a custom `writer` function is provided then this has no effect. **Default:** checking color support on the `output` stream if the REPL instance's `terminal` value is `true`.", "name": "useColors", "type": "boolean", "default": "checking color support on the `output` stream if the REPL instance's `terminal` value is `true`", "desc": "If `true`, specifies that the default `writer` function should include ANSI color styling to REPL output. If a custom `writer` function is provided then this has no effect." }, { "textRaw": "`useGlobal` {boolean} If `true`, specifies that the default evaluation function will use the JavaScript `global` as the context as opposed to creating a new separate context for the REPL instance. The node CLI REPL sets this value to `true`. **Default:** `false`.", "name": "useGlobal", "type": "boolean", "default": "`false`", "desc": "If `true`, specifies that the default evaluation function will use the JavaScript `global` as the context as opposed to creating a new separate context for the REPL instance. The node CLI REPL sets this value to `true`." }, { "textRaw": "`ignoreUndefined` {boolean} If `true`, specifies that the default writer will not output the return value of a command if it evaluates to `undefined`. **Default:** `false`.", "name": "ignoreUndefined", "type": "boolean", "default": "`false`", "desc": "If `true`, specifies that the default writer will not output the return value of a command if it evaluates to `undefined`." }, { "textRaw": "`writer` {Function} The function to invoke to format the output of each command before writing to `output`. **Default:** [`util.inspect()`][].", "name": "writer", "type": "Function", "default": "[`util.inspect()`][]", "desc": "The function to invoke to format the output of each command before writing to `output`." }, { "textRaw": "`completer` {Function} An optional function used for custom Tab auto completion. See [`readline.InterfaceCompleter`][] for an example.", "name": "completer", "type": "Function", "desc": "An optional function used for custom Tab auto completion. See [`readline.InterfaceCompleter`][] for an example." }, { "textRaw": "`replMode` {symbol} A flag that specifies whether the default evaluator executes all JavaScript commands in strict mode or default (sloppy) mode. Acceptable values are:", "name": "replMode", "type": "symbol", "desc": "A flag that specifies whether the default evaluator executes all JavaScript commands in strict mode or default (sloppy) mode. Acceptable values are:", "options": [ { "textRaw": "`repl.REPL_MODE_SLOPPY` to evaluate expressions in sloppy mode.", "name": "repl.REPL_MODE_SLOPPY", "desc": "to evaluate expressions in sloppy mode." }, { "textRaw": "`repl.REPL_MODE_STRICT` to evaluate expressions in strict mode. This is equivalent to prefacing every repl statement with `'use strict'`.", "name": "repl.REPL_MODE_STRICT", "desc": "to evaluate expressions in strict mode. This is equivalent to prefacing every repl statement with `'use strict'`." } ] }, { "textRaw": "`breakEvalOnSigint` {boolean} Stop evaluating the current piece of code when `SIGINT` is received, such as when `Ctrl+C` is pressed. This cannot be used together with a custom `eval` function. **Default:** `false`.", "name": "breakEvalOnSigint", "type": "boolean", "default": "`false`", "desc": "Stop evaluating the current piece of code when `SIGINT` is received, such as when `Ctrl+C` is pressed. This cannot be used together with a custom `eval` function." }, { "textRaw": "`preview` {boolean} Defines if the repl prints autocomplete and output previews or not. **Default:** `true` with the default eval function and `false` in case a custom eval function is used. If `terminal` is falsy, then there are no previews and the value of `preview` has no effect.", "name": "preview", "type": "boolean", "default": "`true` with the default eval function and `false` in case a custom eval function is used. If `terminal` is falsy, then there are no previews and the value of `preview` has no effect", "desc": "Defines if the repl prints autocomplete and output previews or not." } ] } ] } ], "desc": "

The repl.start() method creates and starts a repl.REPLServer instance.

\n

If options is a string, then it specifies the input prompt:

\n
const repl = require('repl');\n\n// a Unix style prompt\nrepl.start('$ ');\n
" } ], "type": "module", "displayName": "REPL" } ] }