"Deno" not recognized in VSC, it's underlined in red. I get the error of "Cannot find name 'Deno'.ts(2304)". In settings, deno is enabled.ings.json,

Viewed 128

For some reason, Visual Studio Code is not recognizing CLI "Deno.args", etc. as seen in the code below. I've checked settings.json and deno is enabled.

import { readStringDelim } from "https://deno.land/std/io/buffer.ts";
async function tail(fileName: string) {
  const fileReader = await Deno.open(fileName);
  await Deno.seek(fileReader.rid, 0, Deno.SeekMode.End);
  const watcher = Deno.watchFs(fileName);
  for await (const event of watcher) {
    if (event.kind !== "modify") continue;
    for await (const line of readStringDelim(fileReader, "\n")) {
      if (!line) break;
      yield (line.trim());
    }
  }
}
const file = Deno.args[0];
if (!file) {
  console.error("File must be provided");
  Deno.exit(1);
}
for await (const line of tail(file)) {
  console.log("Got line:", line);
}
0 Answers
Related