{
  "type": "module",
  "source": "doc/api/repl.md",
  "modules": [
    {
      "textRaw": "REPL",
      "name": "repl",
      "introduced_in": "v0.10.0",
      "type": "module",
      "stability": 2,
      "stabilityText": "Stable",
      "desc": "<p>The <code>node:repl</code> module provides a Read-Eval-Print-Loop (REPL) implementation\nthat is available both as a standalone program or includible in other\napplications. It can be accessed using:</p>\n<pre><code class=\"language-mjs\">import repl from 'node:repl';\n</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node:repl');\n</code></pre>",
      "modules": [
        {
          "textRaw": "Design and features",
          "name": "design_and_features",
          "type": "module",
          "desc": "<p>The <code>node:repl</code> module exports the <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> class. While running,\ninstances of <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> 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 <code>stdin</code> and <code>stdout</code>, respectively, or may\nbe connected to any Node.js <a href=\"stream.html\">stream</a>.</p>\n<p>Instances of <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> support automatic completion of inputs,\ncompletion preview, simplistic Emacs-style line editing, multi-line inputs,\n<a href=\"https://en.wikipedia.org/wiki/Z_shell\">ZSH</a>-like reverse-i-search, <a href=\"https://en.wikipedia.org/wiki/Z_shell\">ZSH</a>-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.</p>",
          "modules": [
            {
              "textRaw": "Commands and special keys",
              "name": "commands_and_special_keys",
              "type": "module",
              "desc": "<p>The following special commands are supported by all REPL instances:</p>\n<ul>\n<li><code>.break</code>: When in the process of inputting a multi-line expression, enter\nthe <code>.break</code> command (or press <kbd>Ctrl</kbd>+<kbd>C</kbd>) to abort\nfurther input or processing of that expression.</li>\n<li><code>.clear</code>: Resets the REPL <code>context</code> to an empty object and clears any\nmulti-line expression being input.</li>\n<li><code>.exit</code>: Close the I/O stream, causing the REPL to exit.</li>\n<li><code>.help</code>: Show this list of special commands.</li>\n<li><code>.save</code>: Save the current REPL session to a file:\n<code>> .save ./file/to/save.js</code></li>\n<li><code>.load</code>: Load a file into the current REPL session.\n<code>> .load ./file/to/load.js</code></li>\n<li><code>.editor</code>: Enter editor mode (<kbd>Ctrl</kbd>+<kbd>D</kbd> to\nfinish, <kbd>Ctrl</kbd>+<kbd>C</kbd> to cancel).</li>\n</ul>\n<pre><code class=\"language-console\">> .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</code></pre>\n<p>The following key combinations in the REPL have these special effects:</p>\n<ul>\n<li><kbd>Ctrl</kbd>+<kbd>C</kbd>: When pressed once, has the same effect as the\n<code>.break</code> command.\nWhen pressed twice on a blank line, has the same effect as the <code>.exit</code>\ncommand.</li>\n<li><kbd>Ctrl</kbd>+<kbd>D</kbd>: Has the same effect as the <code>.exit</code> command.</li>\n<li><kbd>Tab</kbd>: When pressed on a blank line, displays global and local\n(scope) variables. When pressed while entering other input, displays relevant\nautocompletion options.</li>\n</ul>\n<p>For key bindings related to the reverse-i-search, see <a href=\"#reverse-i-search\"><code>reverse-i-search</code></a>.\nFor all other key bindings, see <a href=\"readline.html#tty-keybindings\">TTY keybindings</a>.</p>",
              "displayName": "Commands and special keys"
            },
            {
              "textRaw": "Default evaluation",
              "name": "default_evaluation",
              "type": "module",
              "desc": "<p>By default, all instances of <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> 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 <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> instance is created.</p>",
              "modules": [
                {
                  "textRaw": "JavaScript expressions",
                  "name": "javascript_expressions",
                  "type": "module",
                  "desc": "<p>The default evaluator supports direct evaluation of JavaScript expressions:</p>\n<pre><code class=\"language-console\">> 1 + 1\n2\n> const m = 2\nundefined\n> m + 1\n3\n</code></pre>\n<p>Unless otherwise scoped within blocks or functions, variables declared\neither implicitly or using the <code>const</code>, <code>let</code>, or <code>var</code> keywords\nare declared at the global scope.</p>",
                  "displayName": "JavaScript expressions"
                },
                {
                  "textRaw": "Global and local scope",
                  "name": "global_and_local_scope",
                  "type": "module",
                  "desc": "<p>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 <code>context</code> object associated with each <code>REPLServer</code>:</p>\n<pre><code class=\"language-mjs\">import repl from 'node:repl';\nconst msg = 'message';\n\nrepl.start('> ').context.m = msg;\n</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node:repl');\nconst msg = 'message';\n\nrepl.start('> ').context.m = msg;\n</code></pre>\n<p>Properties in the <code>context</code> object appear as local within the REPL:</p>\n<pre><code class=\"language-console\">$ node repl_test.js\n> m\n'message'\n</code></pre>\n<p>Context properties are not read-only by default. To specify read-only globals,\ncontext properties must be defined using <code>Object.defineProperty()</code>:</p>\n<pre><code class=\"language-mjs\">import repl from 'node: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</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node: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</code></pre>",
                  "displayName": "Global and local scope"
                },
                {
                  "textRaw": "Accessing core Node.js modules",
                  "name": "accessing_core_node.js_modules",
                  "type": "module",
                  "desc": "<p>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 <code>fs</code> will be evaluated on-demand as\n<code>global.fs = require('node:fs')</code>.</p>\n<pre><code class=\"language-console\">> fs.createReadStream('./some/file');\n</code></pre>",
                  "displayName": "Accessing core Node.js modules"
                },
                {
                  "textRaw": "Global uncaught exceptions",
                  "name": "global_uncaught_exceptions",
                  "type": "module",
                  "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": "<p>The REPL uses the <a href=\"domain.html\"><code>domain</code></a> module to catch all uncaught exceptions for that\nREPL session.</p>\n<p>This use of the <a href=\"domain.html\"><code>domain</code></a> module in the REPL has these side effects:</p>\n<ul>\n<li>\n<p>Uncaught exceptions only emit the <a href=\"process.html#event-uncaughtexception\"><code>'uncaughtException'</code></a> event in the\nstandalone REPL. Adding a listener for this event in a REPL within\nanother Node.js program results in <a href=\"errors.html#err_invalid_repl_input\"><code>ERR_INVALID_REPL_INPUT</code></a>.</p>\n<pre><code class=\"language-js\">const r = repl.start();\n\nr.write('process.on(\"uncaughtException\", () => console.log(\"Foobar\"));\\n');\n// Output stream includes:\n//   TypeError [ERR_INVALID_REPL_INPUT]: Listeners for `uncaughtException`\n//   cannot be used in the REPL\n\nr.close();\n</code></pre>\n</li>\n<li>\n<p>Trying to use <a href=\"process.html#processsetuncaughtexceptioncapturecallbackfn\"><code>process.setUncaughtExceptionCaptureCallback()</code></a> throws\nan <a href=\"errors.html#err_domain_cannot_set_uncaught_exception_capture\"><code>ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE</code></a> error.</p>\n</li>\n</ul>",
                  "displayName": "Global uncaught exceptions"
                },
                {
                  "textRaw": "Assignment of the `_` (underscore) variable",
                  "name": "assignment_of_the_`_`_(underscore)_variable",
                  "type": "module",
                  "meta": {
                    "changes": [
                      {
                        "version": "v9.8.0",
                        "pr-url": "https://github.com/nodejs/node/pull/18919",
                        "description": "Added `_error` support."
                      }
                    ]
                  },
                  "desc": "<p>The default evaluator will, by default, assign the result of the most recently\nevaluated expression to the special variable <code>_</code> (underscore).\nExplicitly setting <code>_</code> to a value will disable this behavior.</p>\n<pre><code class=\"language-console\">> [ '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</code></pre>\n<p>Similarly, <code>_error</code> will refer to the last seen error, if there was any.\nExplicitly setting <code>_error</code> to a value will disable this behavior.</p>\n<pre><code class=\"language-console\">> throw new Error('foo');\nUncaught Error: foo\n> _error.message\n'foo'\n</code></pre>",
                  "displayName": "Assignment of the `_` (underscore) variable"
                },
                {
                  "textRaw": "`await` keyword",
                  "name": "`await`_keyword",
                  "type": "module",
                  "desc": "<p>Support for the <code>await</code> keyword is enabled at the top level.</p>\n<pre><code class=\"language-console\">> await Promise.resolve(123)\n123\n> await Promise.reject(new Error('REPL await'))\nUncaught Error: REPL await\n    at REPL2:1:54\n> const timeout = util.promisify(setTimeout);\nundefined\n> const old = Date.now(); await timeout(1000); console.log(Date.now() - old);\n1002\nundefined\n</code></pre>\n<p>One known limitation of using the <code>await</code> keyword in the REPL is that\nit will invalidate the lexical scoping of the <code>const</code> keywords.</p>\n<p>For example:</p>\n<pre><code class=\"language-console\">> const m = await Promise.resolve(123)\nundefined\n> m\n123\n> m = await Promise.resolve(234)\n234\n// redeclaring the constant does error\n> const m = await Promise.resolve(345)\nUncaught SyntaxError: Identifier 'm' has already been declared\n</code></pre>\n<p><a href=\"cli.html#--no-experimental-repl-await\"><code>--no-experimental-repl-await</code></a> shall disable top-level await in REPL.</p>",
                  "displayName": "`await` keyword"
                }
              ],
              "displayName": "Default evaluation"
            },
            {
              "textRaw": "Reverse-i-search",
              "name": "reverse-i-search",
              "type": "module",
              "meta": {
                "added": [
                  "v13.6.0",
                  "v12.17.0"
                ],
                "changes": []
              },
              "desc": "<p>The REPL supports bi-directional reverse-i-search similar to <a href=\"https://en.wikipedia.org/wiki/Z_shell\">ZSH</a>. It is\ntriggered with <kbd>Ctrl</kbd>+<kbd>R</kbd> to search backward\nand <kbd>Ctrl</kbd>+<kbd>S</kbd> to search forwards.</p>\n<p>Duplicated history entries will be skipped.</p>\n<p>Entries are accepted as soon as any key is pressed that doesn't correspond\nwith the reverse search. Cancelling is possible by pressing <kbd>Esc</kbd>\nor <kbd>Ctrl</kbd>+<kbd>C</kbd>.</p>\n<p>Changing the direction immediately searches for the next entry in the expected\ndirection from the current position on.</p>",
              "displayName": "Reverse-i-search"
            },
            {
              "textRaw": "Custom evaluation functions",
              "name": "custom_evaluation_functions",
              "type": "module",
              "desc": "<p>When a new <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> is created, a custom evaluation function may be\nprovided. This can be used, for instance, to implement fully customized REPL\napplications.</p>\n<p>An evaluation function accepts the following four arguments:</p>\n<ul>\n<li><code>code</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> The code to be executed (e.g. <code>1 + 1</code>).</li>\n<li><code>context</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> The context in which the code is executed. This can either be the JavaScript <code>global</code>\ncontext or a context specific to the REPL instance, depending on the <code>useGlobal</code> option.</li>\n<li><code>replResourceName</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> An identifier for the REPL resource associated with the current code\nevaluation. This can be useful for debugging purposes.</li>\n<li><code>callback</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\"><code>&#x3C;Function></code></a> A function to invoke once the code evaluation is complete. The callback takes two parameters:\n<ul>\n<li>An error object to provide if an error occurred during evaluation, or <code>null</code>/<code>undefined</code> if no error occurred.</li>\n<li>The result of the code evaluation (this is not relevant if an error is provided).</li>\n</ul>\n</li>\n</ul>\n<p>The following illustrates an example of a REPL that squares a given number, an error is instead printed\nif the provided input is not actually a number:</p>\n<pre><code class=\"language-mjs\">import repl from 'node:repl';\n\nfunction byThePowerOfTwo(number) {\n  return number * number;\n}\n\nfunction myEval(code, context, replResourceName, callback) {\n  if (isNaN(code)) {\n    callback(new Error(`${code.trim()} is not a number`));\n  } else {\n    callback(null, byThePowerOfTwo(code));\n  }\n}\n\nrepl.start({ prompt: 'Enter a number: ', eval: myEval });\n</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node:repl');\n\nfunction byThePowerOfTwo(number) {\n  return number * number;\n}\n\nfunction myEval(code, context, replResourceName, callback) {\n  if (isNaN(code)) {\n    callback(new Error(`${code.trim()} is not a number`));\n  } else {\n    callback(null, byThePowerOfTwo(code));\n  }\n}\n\nrepl.start({ prompt: 'Enter a number: ', eval: myEval });\n</code></pre>",
              "modules": [
                {
                  "textRaw": "Recoverable errors",
                  "name": "recoverable_errors",
                  "type": "module",
                  "desc": "<p>At the REPL prompt, pressing <kbd>Enter</kbd> sends the current line of input to\nthe <code>eval</code> function. In order to support multi-line input, the <code>eval</code> function\ncan return an instance of <code>repl.Recoverable</code> to the provided callback function:</p>\n<pre><code class=\"language-js\">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</code></pre>",
                  "displayName": "Recoverable errors"
                }
              ],
              "displayName": "Custom evaluation functions"
            },
            {
              "textRaw": "Customizing REPL output",
              "name": "customizing_repl_output",
              "type": "module",
              "desc": "<p>By default, <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> instances format output using the\n<a href=\"util.html#utilinspectobject-options\"><code>util.inspect()</code></a> method before writing the output to the provided <code>Writable</code>\nstream (<code>process.stdout</code> by default). The <code>showProxy</code> inspection option is set\nto true by default and the <code>colors</code> option is set to true depending on the\nREPL's <code>useColors</code> option.</p>\n<p>The <code>useColors</code> boolean option can be specified at construction to instruct the\ndefault writer to use ANSI style codes to colorize the output from the\n<code>util.inspect()</code> method.</p>\n<p>If the REPL is run as standalone program, it is also possible to change the\nREPL's <a href=\"util.html#utilinspectobject-options\">inspection defaults</a> from inside the REPL by using the\n<code>inspect.replDefaults</code> property which mirrors the <code>defaultOptions</code> from\n<a href=\"util.html#utilinspectobject-options\"><code>util.inspect()</code></a>.</p>\n<pre><code class=\"language-console\">> util.inspect.replDefaults.compact = false;\nfalse\n> [1]\n[\n  1\n]\n>\n</code></pre>\n<p>To fully customize the output of a <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> instance pass in a new\nfunction for the <code>writer</code> option on construction. The following example, for\ninstance, simply converts any input text to upper case:</p>\n<pre><code class=\"language-mjs\">import repl from 'node: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</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node: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</code></pre>",
              "displayName": "Customizing REPL output"
            }
          ],
          "displayName": "Design and features"
        },
        {
          "textRaw": "The Node.js REPL",
          "name": "the_node.js_repl",
          "type": "module",
          "desc": "<p>Node.js itself uses the <code>node:repl</code> module to provide its own interactive\ninterface for executing JavaScript. This can be used by executing the Node.js\nbinary without passing any arguments (or by passing the <code>-i</code> argument):</p>\n<pre><code class=\"language-console\">$ 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</code></pre>",
          "modules": [
            {
              "textRaw": "Environment variable options",
              "name": "environment_variable_options",
              "type": "module",
              "desc": "<p>Various behaviors of the Node.js REPL can be customized using the following\nenvironment variables:</p>\n<ul>\n<li><code>NODE_REPL_HISTORY</code>: When a valid path is given, persistent REPL history\nwill be saved to the specified file rather than <code>.node_repl_history</code> in the\nuser's home directory. Setting this value to <code>''</code> (an empty string) will\ndisable persistent REPL history. Whitespace will be trimmed from the value.\nOn Windows platforms environment variables with empty values are invalid so\nset this variable to one or more spaces to disable persistent REPL history.</li>\n<li><code>NODE_REPL_HISTORY_SIZE</code>: Controls how many lines of history will be\npersisted if history is available. Must be a positive number.\n<strong>Default:</strong> <code>1000</code>.</li>\n<li><code>NODE_REPL_MODE</code>: May be either <code>'sloppy'</code> or <code>'strict'</code>. <strong>Default:</strong>\n<code>'sloppy'</code>, which will allow non-strict mode code to be run.</li>\n</ul>",
              "displayName": "Environment variable options"
            },
            {
              "textRaw": "Persistent history",
              "name": "persistent_history",
              "type": "module",
              "desc": "<p>By default, the Node.js REPL will persist history between <code>node</code> REPL sessions\nby saving inputs to a <code>.node_repl_history</code> file located in the user's home\ndirectory. This can be disabled by setting the environment variable\n<code>NODE_REPL_HISTORY=''</code>.</p>",
              "displayName": "Persistent history"
            },
            {
              "textRaw": "Using the Node.js REPL with advanced line-editors",
              "name": "using_the_node.js_repl_with_advanced_line-editors",
              "type": "module",
              "desc": "<p>For advanced line-editors, start Node.js with the environment variable\n<code>NODE_NO_READLINE=1</code>. This will start the main and debugger REPL in canonical\nterminal settings, which will allow use with <code>rlwrap</code>.</p>\n<p>For example, the following can be added to a <code>.bashrc</code> file:</p>\n<pre><code class=\"language-bash\">alias node=\"env NODE_NO_READLINE=1 rlwrap node\"\n</code></pre>",
              "displayName": "Using the Node.js REPL with advanced line-editors"
            },
            {
              "textRaw": "Starting multiple REPL instances in the same process",
              "name": "starting_multiple_repl_instances_in_the_same_process",
              "type": "module",
              "desc": "<p>It is possible to create and run multiple REPL instances against a single\nrunning instance of Node.js that share a single <code>global</code> object (by setting\nthe <code>useGlobal</code> option to <code>true</code>) but have separate I/O interfaces.</p>\n<p>The following example, for instance, provides separate REPLs on <code>stdin</code>, a Unix\nsocket, and a TCP socket, all sharing the same <code>global</code> object:</p>\n<pre><code class=\"language-mjs\">import net from 'node:net';\nimport repl from 'node:repl';\nimport process from 'node:process';\nimport fs from 'node:fs';\n\nlet connections = 0;\n\nrepl.start({\n  prompt: 'Node.js via stdin> ',\n  useGlobal: true,\n  input: process.stdin,\n  output: process.stdout,\n});\n\nconst unixSocketPath = '/tmp/node-repl-sock';\n\n// If the socket file already exists let's remove it\nfs.rmSync(unixSocketPath, { force: true });\n\nnet.createServer((socket) => {\n  connections += 1;\n  repl.start({\n    prompt: 'Node.js via Unix socket> ',\n    useGlobal: true,\n    input: socket,\n    output: socket,\n  }).on('exit', () => {\n    socket.end();\n  });\n}).listen(unixSocketPath);\n\nnet.createServer((socket) => {\n  connections += 1;\n  repl.start({\n    prompt: 'Node.js via TCP socket> ',\n    useGlobal: true,\n    input: socket,\n    output: socket,\n  }).on('exit', () => {\n    socket.end();\n  });\n}).listen(5001);\n</code></pre>\n<pre><code class=\"language-cjs\">const net = require('node:net');\nconst repl = require('node:repl');\nconst fs = require('node:fs');\n\nlet connections = 0;\n\nrepl.start({\n  prompt: 'Node.js via stdin> ',\n  useGlobal: true,\n  input: process.stdin,\n  output: process.stdout,\n});\n\nconst unixSocketPath = '/tmp/node-repl-sock';\n\n// If the socket file already exists let's remove it\nfs.rmSync(unixSocketPath, { force: true });\n\nnet.createServer((socket) => {\n  connections += 1;\n  repl.start({\n    prompt: 'Node.js via Unix socket> ',\n    useGlobal: true,\n    input: socket,\n    output: socket,\n  }).on('exit', () => {\n    socket.end();\n  });\n}).listen(unixSocketPath);\n\nnet.createServer((socket) => {\n  connections += 1;\n  repl.start({\n    prompt: 'Node.js via TCP socket> ',\n    useGlobal: true,\n    input: socket,\n    output: socket,\n  }).on('exit', () => {\n    socket.end();\n  });\n}).listen(5001);\n</code></pre>\n<p>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. <code>telnet</code>,\nfor instance, is useful for connecting to TCP sockets, while <code>socat</code> can be used\nto connect to both Unix and TCP sockets.</p>\n<p>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.</p>",
              "displayName": "Starting multiple REPL instances in the same process"
            },
            {
              "textRaw": "Examples",
              "name": "examples",
              "type": "module",
              "modules": [
                {
                  "textRaw": "Full-featured \"terminal\" REPL over `net.Server` and `net.Socket`",
                  "name": "full-featured_\"terminal\"_repl_over_`net.server`_and_`net.socket`",
                  "type": "module",
                  "desc": "<p>This is an example on how to run a \"full-featured\" (terminal) REPL using\n<a href=\"net.html#class-netserver\"><code>net.Server</code></a> and <a href=\"net.html#class-netsocket\"><code>net.Socket</code></a></p>\n<p>The following script starts an HTTP server on port <code>1337</code> that allows\nclients to establish socket connections to its REPL instance.</p>\n<pre><code class=\"language-mjs\">// repl-server.js\nimport repl from 'node:repl';\nimport net from 'node:net';\n\nnet\n  .createServer((socket) => {\n    const r = repl.start({\n      prompt: `socket ${socket.remoteAddress}:${socket.remotePort}> `,\n      input: socket,\n      output: socket,\n      terminal: true,\n      useGlobal: false,\n    });\n    r.on('exit', () => {\n      socket.end();\n    });\n    r.context.socket = socket;\n  })\n  .listen(1337);\n</code></pre>\n<pre><code class=\"language-cjs\">// repl-server.js\nconst repl = require('node:repl');\nconst net = require('node:net');\n\nnet\n  .createServer((socket) => {\n    const r = repl.start({\n      prompt: `socket ${socket.remoteAddress}:${socket.remotePort}> `,\n      input: socket,\n      output: socket,\n      terminal: true,\n      useGlobal: false,\n    });\n    r.on('exit', () => {\n      socket.end();\n    });\n    r.context.socket = socket;\n  })\n  .listen(1337);\n</code></pre>\n<p>While the following implements a client that can create a socket connection\nwith the above defined server over port <code>1337</code>.</p>\n<pre><code class=\"language-mjs\">// repl-client.js\nimport net from 'node:net';\nimport process from 'node:process';\n\nconst sock = net.connect(1337);\n\nprocess.stdin.pipe(sock);\nsock.pipe(process.stdout);\n\nsock.on('connect', () => {\n  process.stdin.resume();\n  process.stdin.setRawMode(true);\n});\n\nsock.on('close', () => {\n  process.stdin.setRawMode(false);\n  process.stdin.pause();\n  sock.removeListener('close', done);\n});\n\nprocess.stdin.on('end', () => {\n  sock.destroy();\n  console.log();\n});\n\nprocess.stdin.on('data', (b) => {\n  if (b.length === 1 &#x26;&#x26; b[0] === 4) {\n    process.stdin.emit('end');\n  }\n});\n</code></pre>\n<pre><code class=\"language-cjs\">// repl-client.js\nconst net = require('node:net');\n\nconst sock = net.connect(1337);\n\nprocess.stdin.pipe(sock);\nsock.pipe(process.stdout);\n\nsock.on('connect', () => {\n  process.stdin.resume();\n  process.stdin.setRawMode(true);\n});\n\nsock.on('close', () => {\n  process.stdin.setRawMode(false);\n  process.stdin.pause();\n  sock.removeListener('close', done);\n});\n\nprocess.stdin.on('end', () => {\n  sock.destroy();\n  console.log();\n});\n\nprocess.stdin.on('data', (b) => {\n  if (b.length === 1 &#x26;&#x26; b[0] === 4) {\n    process.stdin.emit('end');\n  }\n});\n</code></pre>\n<p>To run the example open two different terminals on your machine, start the server\nwith <code>node repl-server.js</code> in one terminal and <code>node repl-client.js</code> on the other.</p>\n<p>Original code from <a href=\"https://gist.github.com/TooTallNate/2209310\">https://gist.github.com/TooTallNate/2209310</a>.</p>",
                  "displayName": "Full-featured \"terminal\" REPL over `net.Server` and `net.Socket`"
                },
                {
                  "textRaw": "REPL over `curl`",
                  "name": "repl_over_`curl`",
                  "type": "module",
                  "desc": "<p>This is an example on how to run a REPL instance over <a href=\"https://curl.haxx.se/docs/manpage.html\"><code>curl()</code></a></p>\n<p>The following script starts an HTTP server on port <code>8000</code> that can accept\na connection established via <a href=\"https://curl.haxx.se/docs/manpage.html\"><code>curl()</code></a>.</p>\n<pre><code class=\"language-mjs\">import http from 'node:http';\nimport repl from 'node:repl';\n\nconst server = http.createServer((req, res) => {\n  res.setHeader('content-type', 'multipart/octet-stream');\n\n  repl.start({\n    prompt: 'curl repl> ',\n    input: req,\n    output: res,\n    terminal: false,\n    useColors: true,\n    useGlobal: false,\n  });\n});\n\nserver.listen(8000);\n</code></pre>\n<pre><code class=\"language-cjs\">const http = require('node:http');\nconst repl = require('node:repl');\n\nconst server = http.createServer((req, res) => {\n  res.setHeader('content-type', 'multipart/octet-stream');\n\n  repl.start({\n    prompt: 'curl repl> ',\n    input: req,\n    output: res,\n    terminal: false,\n    useColors: true,\n    useGlobal: false,\n  });\n});\n\nserver.listen(8000);\n</code></pre>\n<p>When the above script is running you can then use <a href=\"https://curl.haxx.se/docs/manpage.html\"><code>curl()</code></a> to connect to\nthe server and connect to its REPL instance by running <code>curl --no-progress-meter -sSNT. localhost:8000</code>.</p>\n<p><strong>Warning</strong> This example is intended purely for educational purposes to demonstrate how\nNode.js REPLs can be started using different I/O streams.\nIt should <strong>not</strong> be used in production environments or any context where security\nis a concern without additional protective measures.\nIf you need to implement REPLs in a real-world application, consider alternative\napproaches that mitigate these risks, such as using secure input mechanisms and\navoiding open network interfaces.</p>\n<p>Original code from <a href=\"https://gist.github.com/TooTallNate/2053342\">https://gist.github.com/TooTallNate/2053342</a>.</p>",
                  "displayName": "REPL over `curl`"
                }
              ],
              "displayName": "Examples"
            }
          ],
          "displayName": "The Node.js REPL"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: `REPLServer`",
          "name": "REPLServer",
          "type": "class",
          "meta": {
            "added": [
              "v0.1.91"
            ],
            "changes": []
          },
          "desc": "<ul>\n<li><code>options</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object\"><code>&#x3C;Object></code></a> | <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> See <a href=\"#replstartoptions\"><code>repl.start()</code></a></li>\n<li>Extends: <a href=\"readline.html#class-readlineinterface\"><code>&#x3C;readline.Interface></code></a></li>\n</ul>\n<p>Instances of <code>repl.REPLServer</code> are created using the <a href=\"#replstartoptions\"><code>repl.start()</code></a> method\nor directly using the JavaScript <code>new</code> keyword.</p>\n<pre><code class=\"language-mjs\">import repl from 'node:repl';\n\nconst options = { useColors: true };\n\nconst firstInstance = repl.start(options);\nconst secondInstance = new repl.REPLServer(options);\n</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node:repl');\n\nconst options = { useColors: true };\n\nconst firstInstance = repl.start(options);\nconst secondInstance = new repl.REPLServer(options);\n</code></pre>",
          "events": [
            {
              "textRaw": "Event: `'exit'`",
              "name": "exit",
              "type": "event",
              "meta": {
                "added": [
                  "v0.7.7"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>The <code>'exit'</code> event is emitted when the REPL is exited either by receiving the\n<code>.exit</code> command as input, the user pressing <kbd>Ctrl</kbd>+<kbd>C</kbd> twice\nto signal <code>SIGINT</code>,\nor by pressing <kbd>Ctrl</kbd>+<kbd>D</kbd> to signal <code>'end'</code> on the input\nstream. The listener\ncallback is invoked without any arguments.</p>\n<pre><code class=\"language-js\">replServer.on('exit', () => {\n  console.log('Received \"exit\" event from repl!');\n  process.exit();\n});\n</code></pre>"
            },
            {
              "textRaw": "Event: `'reset'`",
              "name": "reset",
              "type": "event",
              "meta": {
                "added": [
                  "v0.11.0"
                ],
                "changes": []
              },
              "params": [],
              "desc": "<p>The <code>'reset'</code> event is emitted when the REPL's context is reset. This occurs\nwhenever the <code>.clear</code> command is received as input <em>unless</em> the REPL is using\nthe default evaluator and the <code>repl.REPLServer</code> instance was created with the\n<code>useGlobal</code> option set to <code>true</code>. The listener callback will be called with a\nreference to the <code>context</code> object as the only argument.</p>\n<p>This can be used primarily to re-initialize REPL context to some pre-defined\nstate:</p>\n<pre><code class=\"language-mjs\">import repl from 'node: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</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node: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</code></pre>\n<p>When this code is executed, the global <code>'m'</code> variable can be modified but then\nreset to its initial value using the <code>.clear</code> command:</p>\n<pre><code class=\"language-console\">$ ./node example.js\n> m\n'test'\n> m = 1\n1\n> m\n1\n> .clear\nClearing context...\n> m\n'test'\n>\n</code></pre>"
            }
          ],
          "methods": [
            {
              "textRaw": "`replServer.defineCommand(keyword, cmd)`",
              "name": "defineCommand",
              "type": "method",
              "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": "<p>The <code>replServer.defineCommand()</code> method is used to add new <code>.</code>-prefixed commands\nto the REPL instance. Such commands are invoked by typing a <code>.</code> followed by the\n<code>keyword</code>. The <code>cmd</code> is either a <code>Function</code> or an <code>Object</code> with the following\nproperties:</p>\n<ul>\n<li><code>help</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type\"><code>&#x3C;string></code></a> Help text to be displayed when <code>.help</code> is entered (Optional).</li>\n<li><code>action</code> <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function\"><code>&#x3C;Function></code></a> The function to execute, optionally accepting a single\nstring argument.</li>\n</ul>\n<p>The following example shows two new commands added to the REPL instance:</p>\n<pre><code class=\"language-mjs\">import repl from 'node: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</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node: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</code></pre>\n<p>The new commands can then be used from within the REPL instance:</p>\n<pre><code class=\"language-console\">> .sayhello Node.js User\nHello, Node.js User!\n> .saybye\nGoodbye!\n</code></pre>"
            },
            {
              "textRaw": "`replServer.displayPrompt([preserveCursor])`",
              "name": "displayPrompt",
              "type": "method",
              "meta": {
                "added": [
                  "v0.1.91"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`preserveCursor` {boolean}",
                      "name": "preserveCursor",
                      "type": "boolean",
                      "optional": true
                    }
                  ]
                }
              ],
              "desc": "<p>The <code>replServer.displayPrompt()</code> method readies the REPL instance for input\nfrom the user, printing the configured <code>prompt</code> to a new line in the <code>output</code>\nand resuming the <code>input</code> to accept new input.</p>\n<p>When multi-line input is being entered, a pipe <code>'|'</code> is printed rather than the\n'prompt'.</p>\n<p>When <code>preserveCursor</code> is <code>true</code>, the cursor placement will not be reset to <code>0</code>.</p>\n<p>The <code>replServer.displayPrompt</code> method is primarily intended to be called from\nwithin the action function for commands registered using the\n<code>replServer.defineCommand()</code> method.</p>"
            },
            {
              "textRaw": "`replServer.clearBufferedCommand()`",
              "name": "clearBufferedCommand",
              "type": "method",
              "meta": {
                "added": [
                  "v9.0.0"
                ],
                "changes": []
              },
              "signatures": [
                {
                  "params": []
                }
              ],
              "desc": "<p>The <code>replServer.clearBufferedCommand()</code> 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\n<code>replServer.defineCommand()</code> method.</p>"
            },
            {
              "textRaw": "`replServer.setupHistory(historyConfig, callback)`",
              "name": "setupHistory",
              "type": "method",
              "meta": {
                "added": [
                  "v11.10.0"
                ],
                "changes": [
                  {
                    "version": "v24.2.0",
                    "pr-url": "https://github.com/nodejs/node/pull/58225",
                    "description": "Updated the `historyConfig` parameter to accept an object with `filePath`, `size`, `removeHistoryDuplicates` and `onHistoryFileLoaded` properties."
                  }
                ]
              },
              "signatures": [
                {
                  "params": [
                    {
                      "textRaw": "`historyConfig` {Object|string} the path to the history file If it is a string, it is the path to the history file. If it is an object, it can have the following properties:",
                      "name": "historyConfig",
                      "type": "Object|string",
                      "desc": "the path to the history file If it is a string, it is the path to the history file. If it is an object, it can have the following properties:",
                      "options": [
                        {
                          "textRaw": "`filePath` {string} the path to the history file",
                          "name": "filePath",
                          "type": "string",
                          "desc": "the path to the history file"
                        },
                        {
                          "textRaw": "`size` {number} Maximum number of history lines retained. To disable the history set this value to `0`. This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check, otherwise the history caching mechanism is not initialized at all. **Default:** `30`.",
                          "name": "size",
                          "type": "number",
                          "default": "`30`",
                          "desc": "Maximum number of history lines retained. To disable the history set this value to `0`. This option makes sense only if `terminal` is set to `true` by the user or by an internal `output` check, otherwise the history caching mechanism is not initialized at all."
                        },
                        {
                          "textRaw": "`removeHistoryDuplicates` {boolean} If `true`, when a new input line added to the history list duplicates an older one, this removes the older line from the list. **Default:** `false`.",
                          "name": "removeHistoryDuplicates",
                          "type": "boolean",
                          "default": "`false`",
                          "desc": "If `true`, when a new input line added to the history list duplicates an older one, this removes the older line from the list."
                        },
                        {
                          "textRaw": "`onHistoryFileLoaded` {Function} called when history writes are ready or upon error",
                          "name": "onHistoryFileLoaded",
                          "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"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "textRaw": "`callback` {Function} called when history writes are ready or upon error (Optional if provided as `onHistoryFileLoaded` in `historyConfig`)",
                      "name": "callback",
                      "type": "Function",
                      "desc": "called when history writes are ready or upon error (Optional if provided as `onHistoryFileLoaded` in `historyConfig`)",
                      "options": [
                        {
                          "textRaw": "`err` {Error}",
                          "name": "err",
                          "type": "Error"
                        },
                        {
                          "textRaw": "`repl` {repl.REPLServer}",
                          "name": "repl",
                          "type": "repl.REPLServer"
                        }
                      ]
                    }
                  ]
                }
              ],
              "desc": "<p>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.</p>"
            }
          ]
        }
      ],
      "properties": [
        {
          "textRaw": "Type: {string[]}",
          "name": "builtinModules",
          "type": "string[]",
          "meta": {
            "added": [
              "v14.5.0"
            ],
            "changes": [],
            "deprecated": [
              "v24.0.0",
              "v22.16.0"
            ]
          },
          "stability": 0,
          "stabilityText": "Deprecated. Use `module.builtinModules` instead.",
          "desc": "<p>A list of the names of some Node.js modules, e.g., <code>'http'</code>.</p>\n<p>An automated migration is available (<a href=\"https://github.com/nodejs/userland-migrations/tree/main/recipes/repl-builtin-modules\">source</a>):</p>\n<pre><code class=\"language-bash\">npx codemod@latest @nodejs/repl-builtin-modules\n</code></pre>"
        }
      ],
      "methods": [
        {
          "textRaw": "`repl.start([options])`",
          "name": "start",
          "type": "method",
          "meta": {
            "added": [
              "v0.1.91"
            ],
            "changes": [
              {
                "version": "v26.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/62188",
                "description": "The `handleError` parameter has been added."
              },
              {
                "version": "v24.1.0",
                "pr-url": "https://github.com/nodejs/node/pull/58003",
                "description": "Added the possibility to add/edit/remove multilines while adding a multiline command."
              },
              {
                "version": "v24.0.0",
                "pr-url": "https://github.com/nodejs/node/pull/57400",
                "description": "The multi-line indicator is now \"|\" instead of \"...\". Added support for multi-line history. It is now possible to \"fix\" multi-line commands with syntax errors by visiting the history and editing the command. When visiting the multiline history from an old node version, the multiline structure is not preserved."
              },
              {
                "version": [
                  "v13.4.0",
                  "v12.17.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": "v6.3.0",
                "pr-url": "https://github.com/nodejs/node/pull/6635",
                "description": "The `breakEvalOnSigint` option is supported now."
              },
              {
                "version": "v5.8.0",
                "pr-url": "https://github.com/nodejs/node/pull/5388",
                "description": "The `options` parameter is optional now."
              }
            ]
          },
          "signatures": [
            {
              "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. See the custom evaluation functions section for more details.",
                      "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. See the custom evaluation functions section for more details",
                      "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 <kbd>Ctrl</kbd>+<kbd>C</kbd> 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 <kbd>Ctrl</kbd>+<kbd>C</kbd> 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."
                    },
                    {
                      "textRaw": "`handleError` {Function} This function customizes error handling in the REPL. It receives the thrown exception as its first argument and must return one of the following values synchronously:",
                      "name": "handleError",
                      "type": "Function",
                      "desc": "This function customizes error handling in the REPL. It receives the thrown exception as its first argument and must return one of the following values synchronously:",
                      "options": [
                        {
                          "textRaw": "`'print'` to print the error to the output stream (default behavior).",
                          "desc": "`'print'` to print the error to the output stream (default behavior)."
                        },
                        {
                          "textRaw": "`'ignore'` to skip all remaining error handling.",
                          "desc": "`'ignore'` to skip all remaining error handling."
                        },
                        {
                          "textRaw": "`'unhandled'` to treat the exception as fully unhandled. In this case, the error will be passed to process-wide exception handlers, such as the `'uncaughtException'` event. The `'unhandled'` value may or may not be desirable in situations where the `REPLServer` instance has been closed, depending on the particular use case.",
                          "desc": "`'unhandled'` to treat the exception as fully unhandled. In this case, the error will be passed to process-wide exception handlers, such as the `'uncaughtException'` event. The `'unhandled'` value may or may not be desirable in situations where the `REPLServer` instance has been closed, depending on the particular use case."
                        }
                      ]
                    }
                  ],
                  "optional": true
                }
              ],
              "return": {
                "textRaw": "Returns: {repl.REPLServer}",
                "name": "return",
                "type": "repl.REPLServer"
              }
            }
          ],
          "desc": "<p>The <code>repl.start()</code> method creates and starts a <a href=\"#class-replserver\"><code>repl.REPLServer</code></a> instance.</p>\n<p>If <code>options</code> is a string, then it specifies the input prompt:</p>\n<pre><code class=\"language-mjs\">import repl from 'node:repl';\n\n// a Unix style prompt\nrepl.start('$ ');\n</code></pre>\n<pre><code class=\"language-cjs\">const repl = require('node:repl');\n\n// a Unix style prompt\nrepl.start('$ ');\n</code></pre>"
        }
      ],
      "displayName": "REPL"
    }
  ]
}