replServer.setupHistory(historyPath, callback)

初始化 REPL 实例的历史日志文件。 当执行 Node.js 二进制文件并使用命令行 REPL 时,默认情况下会初始化一个历史文件。 但是,以编程方式创建 REPL 时并非如此。 在以编程方式使用 REPL 实例时,使用此方法初始化历史日志文件。

Initializes a history log file for the REPL instance. When executing the Node.js binary and using the command-line REPL, a history file is initialized by default. However, this is not the case when creating a REPL programmatically. Use this method to initialize a history log file when working with REPL instances programmatically.