Error when using readline.question()

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))
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.
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.
4 Replies
marvinh.
marvinh.15mo ago
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
!Roricchi 2.0『藤田の妻』
ooh, please tell me ty MelWow
marvinh.
marvinh.15mo ago