Issue
I can't type in terminal when prompted for user input. Here's the code I'm using:
import * as readLine from 'readline'
const rl = readLine.createInterface({
input: process.stdin,
output: process.stdout
})
rl.question('Enter your choice..: ', (answer) => {
console.log(answer)
})
Im running it through console by npm run main
with the following scripts in package.json:
"premain": "rimraf dist && tsc",
"main": "concurrently \"tsc -w\" \"node dist/index.js\""
I've tried:
- Adding
"code-runner.runInTerminal": true
to settings.json - Enabling Legacy Terminal
Solution
For me it works if you just open the app directly using
node yourapp.js
you will need to put "type": "module"
in package.json.
If you want to use npm run dev
you have to add a dev script to package.json:
"scripts": { "dev": "node app.js"}
Answered By - Kokodoko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.