类:REPLServer
🌐 Class: REPLServer
options<Object> | <string> 见repl.start()- 扩展自: <readline.Interface>
可以使用 repl.start() 方法创建 repl.REPLServer 的实例,或者直接使用 JavaScript 的 new 关键字。
🌐 Instances of repl.REPLServer are created using the repl.start() method
or directly using the JavaScript new keyword.
import repl from 'node:repl';
const options = { useColors: true };
const firstInstance = repl.start(options);
const secondInstance = new repl.REPLServer(options);const repl = require('node:repl');
const options = { useColors: true };
const firstInstance = repl.start(options);
const secondInstance = new repl.REPLServer(options);在没有 new 关键字的情况下调用 repl.REPLServer() 会抛出 TypeError(见 DEP0185)。
🌐 Calling repl.REPLServer() without the new keyword throws a TypeError
(see DEP0185).