const prompt = require("prompt-sync")();
var fname = prompt("Enter your first name: ");
var lname = prompt("Enter your last name: ");
console.log("Your full name is", fname, lname);
I tried running the above code of javascript on vscode and the error popping up is
node:internal/fs/utils:350
throw err;
^
Error: ENXIO: no such device or address, open '/dev/tty'
I have installed nodejs and javascript ES6 intellisense. I also ran the npm install prompt-sync command on the terminal before running the program.
>Solution :
Make sure you ran the program in a terminal (with npm start or node yourScript.js). The error essentially means there is no terminal to take the input from.
If you run it through VS Code as a task then the output will be captured and displayed to you, but there is no interactive terminal attached that would take input for the program. That’s why the program fails trying to open the terminal device.
