Closed GNUGradyn closed 6 years ago
@GNUGradyn You must instantiate a new prompt instance before you can use it.
Per the examle
const promp = require('promp-sync')();
which sets prompts as a function with the default settings
alternatively
const promp = require('promp-sync')({
'fake_val': 'OPTIONAL CONFIG VALUES HERE'
});
Will let you change the default config options
What about import? I get the same error with:
import prompt from 'prompt-sync';
const name = prompt('What is your name?');
console.log(`Hey there ${name}`);
var autocomplete = config.autocomplete =
^
TypeError: Cannot create property 'autocomplete' on string 'What is your name?'
@Pawel-Stankiewicz, this will work in case of import
import promptSync from 'prompt-sync'; const prompt = promptSync(); const name = prompt('Name: ');
I'm doing an import but getting the same error: Cannot create property 'autocomplete' on string The code is:
const prompt = require("prompt-sync")();
const deposit = () => { const depositAmount = prompt("Enter a deposit amount: "); };
deposit();
Code:
result: