<!-- Thank you for reporting an issue. This issue tracker is for bugs and issues found within Node.js core. If you require more general support please file an issue on our help repo. https://github.com/nodejs/help Please fill in as much of the template below as you're able. Version: output of `node -v` Platform: output of `uname -a` (UNIX), or output of `"$([Environment]::OSVersion | ForEach-Object VersionString) $(if ([Environment]::Is64BitOperatingSystem) { "x64" } else { "x86" })"` in PowerShell console (Windows) Subsystem: if known, please specify affected core module name --> * **Version**: master * **Platform**: Ubuntu 20.04 * **Subsystem**: repl ### What steps will reproduce the bug? ```js 'use strict'; const repl = require('repl'); const r = repl.start({ terminal: false }); r.setupHistory('/nonexistent/file', (err) => console.log(err)); ``` ### How often does it reproduce? Is there a required condition? Always ### What is the expected behavior? No error (beyond the warning message) ### What do you see instead? ``` $ node repltest.js > Error: Could not open history file. REPL session history will not be persisted. node:readline:794 StringPrototypeSlice(this.line, 0, this.cursor); ^ TypeError: String.prototype.slice called on null or undefined at slice (<anonymous>) at REPLServer.Interface.getCursorPos (node:readline:794:27) at REPLServer.Interface._refreshLine (node:readline:419:26) at _writeToOutput (node:internal/repl/history:30:8) at oninit (node:internal/repl/history:69:7) at FSReqCallback.oncomplete (node:fs:184:23) at FSReqCallback.callbackTrampoline (node:internal/async_hooks:131:14) ```