Socket
Book a DemoInstallSign in
Socket

node-repl-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-repl-polyfill

node:repl polyfill for other JS runtimes

latest
Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
37
-15.91%
Maintainers
1
Weekly downloads
 
Created
Source

node-repl-polyfill

Simple node:repl polyfill for other JS runtimes which do not support node:repl (eg Deno, Bun).

This polyfill does not aim to have full parity but provide a basic library for people wanting to use the basics of node:repl. The default eval function is intentionally terrible, as it is expected you are bringing your own. With these limitations, it should act like a "drop-in" replacement for node:repl by just importing this package instead of node:repl. This package does no detection for native support of node:repl, so does not try to use a native implementation at all.


npm install node-repl-polyfill

You can use the following import as to use node:repl if supported by the runtime being used:

let repl;
try {
  // try importing node:repl
  repl = await import('node:repl');

  // check it is not just a mock with REPLServer prototype
  if (repl.REPLServer.prototype.defineCommand == null)
    throw 'mock node:repl detected';
} catch {
  // it failed, import the polyfill
  repl = (await import('node-repl-polyfill')).default;
}

Runtime requirements

This polyfill relies on the runtime supporting:

  • node:process (stdin, stdout)
  • node:util (inspect)
  • node:readline (Interface)

Runtimes tested:

  • Node (20.12.0)
  • Deno (1.42.2)
  • Bun (1.1.5)

Keywords

repl

FAQs

Package last updated on 27 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts