Inquirer.js
Inquirer.js copied to clipboard
List Selected Highlight not changing on arrow key press
I'm having an issue with running Inquirer in the Mac terminal where when using the 'list' type, the highlighted selection arrow/font style will not move up and down with arrow key presses.
In this screenshot, I have pressed the down arrow key twice, and thus the selection choice is actually on 'other', but that selection is not being displayed properly in the UI.
Which node version? Did you try updating it?
I'm currently on v6.10. I just saw that the recommended version for node is v6.11...not sure if you still think i should try updating.
Yes, try updating to the latest node v6.x
Experiencing the same issues on v6.11...additionally had a friend try on v8.4 and didn't work.
Can you post your code?
var inquirer = require('inquirer');
var prompt = inquirer.createPromptModule();
/** VERIFY INITIAL COMMAND PROMPT QUESTION INFO **/
let commandPromptQuestions = {
type: 'list',
name: 'command',
message: 'What operation do you want to perform next?',
choices: ['this', 'that', 'other', 'next']
};
/** TAKE IN USER INPUTTED COMMAND AND PASS THROUGH SWITCH STATEMENT **/
let commandPrompt = () => {
prompt(commandPromptQuestions)
.then(answers => {
commandRunner(answers.command);
})
.catch(error => {
console.log('There was an error with this command! Try again');
commandPrompt();
})
}```
hey! Wanted to see if you had any updates on this issue?? Let me know. Does it seem like I am implementing it correctly given the code above?
Looking at the code yes, but it's not a complete example. So there could be other modules touching the TTY that are conflicting with inquirer.
It'll be hard to really help without a full example I can run and reproduce.
I was testing it out as a tool so I actually just have a basic server set up with that command you have above (commandRunner was just console logging). I will create a repo for it, push it up and send you the link so you could see everything.
https://github.com/dsc03/clitool
^^ that was the playground i was testing inquire with and where I was getting issues...the only additional module I'm using in this case is express.
hey! Any updates on this?
this is because of terminal plugins like i use zsh
it doesn't works here, but when i shifted to bash it works fine.
we can solve that by adding a script in package.json
"start":"echo bash && node index.js",
on npm start
it will start bash
shell and execute the programme. and in bash shell you can use .
remember this bash only works in UNIX
based systems. not in windows.
same issue and I'm on node v10.9.0
I was having the same issue on Windows 10, Node 11, but I just upgrade to Node 12.2.0 / npm 6.9.0 and the problem went away. Hope this helps someone!
Running nodemon in the npm start script caused this issue for me.
I had this:
"scripts": { "start": "nodemon --exec babel-node index.js" }
Changed it to this. Now my keypresses work as expected:
"scripts": { "start": "babel-node index.js" }
Running nodemon in the npm start script caused this issue for me. I had this:
"scripts": { "start": "nodemon --exec babel-node index.js" }
Changed it to this. Now my keypresses work as expected:"scripts": { "start": "babel-node index.js" }
Same issue here, nodemon was the culprit as soon as I changed it to
"scripts": { "start": "node index.js" }
it worked as expected.
@AgkTF @knaut Try the -I
option from nodemon:
-I, --no-stdin ........... nodemon passes stdin directly to child process
"scripts": { "start": "nodemon -I --exec babel-node index.js" }
That is working for me.
Running nodemon in the npm start script caused this issue for me. I had this:
"scripts": { "start": "nodemon --exec babel-node index.js" }
Changed it to this. Now my keypresses work as expected:"scripts": { "start": "babel-node index.js" }
Same issue here, nodemon was the culprit as soon as I changed it to
"scripts": { "start": "node index.js" }
it worked as expected.
This fixed it for me, too! Nodemon doesn't like it.
@AgkTF @knaut Try the
-I
option from nodemon:
-I, --no-stdin ........... nodemon passes stdin directly to child process
"scripts": { "start": "nodemon -I --exec babel-node index.js" }
That is working for me.
Awesome.. worked like charm
Nodemon seems to have been the culprit for me. Once I removed nodemon, it worked!
I had this before:
"scripts": { "start": "nodemon --watch 'src/**/*.ts' --exec \"npx ts-node\" index.ts" }
Changed to this and it worked:
"scripts": { "start": "ts-node index.ts" }