Skip to content
Browse files

repl: remove magic mode

The magic mode is long deprecated and works the same as the sloppy
mode. Since the sloppy mode is the default, removing the magic mode
should be safe.

PR-URL: #19187
Reviewed-By: Colin Ihrig <>
Reviewed-By: Michaël Zasso <>
Reviewed-By: Tiancheng "Timothy" Gu <>
Reviewed-By: Sakthipriyan Vairamani <>
Reviewed-By: Сковорода Никита Андреевич <>
  • Loading branch information
BridgeAR committed Mar 11, 2018
1 parent 8181c60 commit 4893f70d12691208abf8c668d8347240df561f14
Showing with 12 additions and 24 deletions.
  1. +4 −4 doc/api/
  2. +5 −6 doc/api/
  3. +0 −1 lib/repl.js
  4. +3 −13 test/parallel/test-repl-options.js
@@ -560,16 +560,16 @@ The `tls.createSecurePair()` API was deprecated in documentation in Node.js
<a id="DEP0065"></a>
### DEP0065: repl.REPL_MODE_MAGIC and NODE_REPL_MODE=magic

Type: Documentation-only
Type: End-of-Life

The `repl` module's `REPL_MODE_MAGIC` constant, used for `replMode` option, has
been deprecated. Its behavior has been functionally identical to that of
been removed. Its behavior has been functionally identical to that of
`REPL_MODE_SLOPPY` since Node.js v6.0.0, when V8 5.0 was imported. Please use

The `NODE_REPL_MODE` environment variable is used to set the underlying
`replMode` of an interactive `node` session. Its default value, `magic`, is
similarly deprecated in favor of `sloppy`.
`replMode` of an interactive `node` session. Its value, `magic`, is also
removed. Please use `sloppy` instead.

<a id="DEP0066"></a>
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames
@@ -421,6 +421,9 @@ Returns `true` if `keyword` is a valid keyword, otherwise `false`.
<!-- YAML
added: v0.1.91
- version: REPLACEME
description: The `REPL_MAGIC_MODE` replMode was removed.
- version: v5.8.0
description: The `options` parameter is optional now.
@@ -462,9 +465,6 @@ changes:
* `repl.REPL_MODE_SLOPPY` - evaluates expressions in sloppy mode.
* `repl.REPL_MODE_STRICT` - evaluates expressions in strict mode. This is
equivalent to prefacing every repl statement with `'use strict'`.
* `repl.REPL_MODE_MAGIC` - This value is **deprecated**, since enhanced
spec compliance in V8 has rendered magic mode unnecessary. It is now
equivalent to `repl.REPL_MODE_SLOPPY` (documented above).
* `breakEvalOnSigint` - Stop evaluating the current piece of code when
`SIGINT` is received, i.e. `Ctrl+C` is pressed. This cannot be used together
with a custom `eval` function. Defaults to `false`.
@@ -512,9 +512,8 @@ environment variables:
REPL history. Whitespace will be trimmed from the value.
- `NODE_REPL_HISTORY_SIZE` - Defaults to `1000`. Controls how many lines of
history will be persisted if history is available. Must be a positive number.
- `NODE_REPL_MODE` - May be any of `sloppy`, `strict`, or `magic`. Defaults
to `sloppy`, which will allow non-strict mode code to be run. `magic` is
**deprecated** and treated as an alias of `sloppy`.
- `NODE_REPL_MODE` - May be either `sloppy` or `strict`. Defaults
to `sloppy`, which will allow non-strict mode code to be run.

### Persistent History

@@ -716,7 +716,6 @@ exports.REPLServer = REPLServer;

exports.REPL_MODE_SLOPPY = Symbol('repl-sloppy');
exports.REPL_MODE_STRICT = Symbol('repl-strict');

// prompt is a string to print on each line for the prompt,
// source is a stream to use for I/O, defaulting to stdin/stdout.
@@ -67,7 +67,8 @@ const r2 = repl.start({
ignoreUndefined: true,
eval: evaler,
writer: writer,
replMode: repl.REPL_MODE_STRICT
replMode: repl.REPL_MODE_STRICT,
historySize: 50
assert.strictEqual(r2.input, stream);
assert.strictEqual(r2.output, stream);
@@ -79,6 +80,7 @@ assert.strictEqual(r2.useGlobal, true);
assert.strictEqual(r2.ignoreUndefined, true);
assert.strictEqual(r2.writer, writer);
assert.strictEqual(r2.replMode, repl.REPL_MODE_STRICT);
assert.strictEqual(r2.historySize, 50);

// test r2 for backwards compact
assert.strictEqual(r2.rli.input, stream);
@@ -87,18 +89,6 @@ assert.strictEqual(r2.rli.input, r2.inputStream);
assert.strictEqual(r2.rli.output, r2.outputStream);
assert.strictEqual(r2.rli.terminal, false);

// testing out "magic" replMode
const r3 = repl.start({
input: stream,
output: stream,
writer: writer,
replMode: repl.REPL_MODE_MAGIC,
historySize: 50

assert.strictEqual(r3.replMode, repl.REPL_MODE_MAGIC);
assert.strictEqual(r3.historySize, 50);

// Verify that defaults are used when no arguments are provided
const r4 = repl.start();

0 comments on commit 4893f70

Please sign in to comment.