#Error when using readline.question()

1 messages · Page 1 of 1 (latest)

raw swan
#

I get this error with the following code

import process from 'node:process'
import readline from 'node:readline'

let intf = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

intf.question('Enter name :', name => console.log(name))
error: Uncaught ReferenceError: process is not defined
  intf.question('Enter name :', name => console.log(name))
       ^
    at Interface.prompt (ext:deno_node/internal/readline/interface.mjs:377:26)     
    at Interface.[kQuestion] (ext:deno_node/internal/readline/interface.mjs:395:12)
    at Interface.question (ext:deno_node/_readline.mjs:144:20)
    at file:///C:/my_project_path/main.ts:39:7
    at ext:deno_node/_fs/_fs_readFile.ts:29:25
    at eventLoopTick (ext:core/01_core.js:181:11)
NativeCommandExitException: Program "deno.exe" ended with non-zero exit code: 1.
hot crescent
#

Ah that is a bug in the node compatibility layer in deno. Looks like it tries to access the process global before it's set as a global. I got a fix working locally

hot crescent