D
Deno

help

Error when using readline.question()

R!Roricchi 2.0『藤田の妻』5/18/2023
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.
Mmarvinh.5/18/2023
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
R!Roricchi 2.0『藤田の妻』5/18/2023
ooh, please tell me ty MelWow
Mmarvinh.5/18/2023
R!Roricchi 2.0『藤田の妻』5/19/2023
peepoheart

Looking for more? Join the community!