I am starting to work with deno and typescript, and after some experimentation I figured out how to import code from other modules and such, and now I needed to create a simple script to take a given input in the console and then output a particular message depending on the message. I realize that this has something to do with dependencies and what the compiler looks for, but I'm really not sure how to set it up. Here is my code in its entirety:
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();
});
And here is the error I am getting:
What is required for me to fix this
Edit: I had already run npm i @types/node
previous to this screenshot, and it did not change anything.
If you want to read stdin from Deno, you can use this standard library
readlines
. Here is a snippet:Also, you can import old modules like you did in your snippet, but Deno support this imports from a url, which is much more easy