在简单输入脚本中找不到名称 "process"

Cannot find name "process" in simple input script

我开始使用 deno 和 typescript,经过一些实验,我想出了如何从其他模块等导入代码,现在我需要创建一个简单的脚本来在控制台中获取给定的输入,然后然后根据消息输出特定消息。我意识到这与依赖关系和编译器寻找的内容有关,但我真的不确定如何设置它。这是我的完整代码:

import * as readline from './node_modules/readline/readline.js';

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

rl.question('yes or no bitch', (answer:any) => {
  switch(answer.toLowerCase()) {
    case 'y':
      console.log('noice');
      break;
    case 'n':
      console.log("okay bitch");
      break;
    default:
      console.log("no.");
  }
  rl.close();
});

这是我收到的错误:

我需要什么来解决这个问题

编辑:在这张截图之前我已经 运行 npm i @types/node,它没有改变任何东西。

如果你想从 Deno 读取标准输入,你可以使用这个标准库 readlines。这是一个片段:

import { readLines } from "https://deno.land/std/io/buffer.ts";

for await (const line of readLines(Deno.stdin)) {
   switch(line.toLowerCase()) {
    case 'y':
      console.log('noice');
      break;
    case 'n':
      console.log("okay bitch");
      break;
    default:
      console.log("no.");
  }
}

此外,您可以像在代码片段中那样导入旧模块,但 Deno 支持从 url 导入,这要容易得多