Autocomplete error
Opened this issue · 3 comments
AlfonsoC06 commented
Code:
import prompt from 'prompt-sync';
var gender = prompt('Are you a male or a female? (M - male, F - female)');
if(gender == 'M' || gender == 'F'){
console.log(gender);
} else {
console.log('Try again!');
}
Error:
var autocomplete = config.autocomplete =
^
TypeError: Cannot create property 'autocomplete' on string 'Are you a male or a female? (M - male, F - female)'
aayusharyan commented
I am not sure about import approach, but I faced a similar issue when using prompt with require.
The way it is intended to work is like this.
const prompt_fn = require('prompt-sync');
const prompt = prompt_fn();
mfcastilho commented
I was having the same problem. Your answer helped me a lot! Thanks!
Jolly-Pirate commented
Previously answered #29 for both types of import (require and es6 module).