Search code examples
javascriptnode.jsprompt

NodeJS prompt customization


I need to remove "prompt:" line on cmd. How can I do? Example code:

prompt.start();
prompt.get([{name: 'username', required: true}], function (err, result) { if (err) { return onErr(err); }
    console.log('Your username: ' + result.username);
});

OUTPUT:

prompt: username:

I don't want prompt:


Solution

  • Make the prompt.message property falsey, like so:

    
    prompt.message = null;
    
    prompt.start();
    prompt.get([{name: 'username', required: true}], function (err, result) { if (err) { return onErr(err); }
        console.log('Your username: ' + result.username);
    });
    

    As documented in the Customizing Your Prompt section of the docs