Inquirer.js icon indicating copy to clipboard operation
Inquirer.js copied to clipboard

"Cannot read property 'pipe' of undefined" - Error

Open ManavGhaiCode opened this issue 3 years ago • 2 comments

hello devs of Inquirer JS, I am make a password-manager for my self. When I found this error and not use pipe anywhere, the file which had the error was "/home/manav/code/password-manager/node_modules/inquirer/lib/ui/prompt.js". I am also going to my code.

index.js -

try {
    require('dotenv').config();

    const questions = require('./utils/questions');
    const { prompt } = require('./utils/promtShell')

    master = prompt(questions[0]);

    if (master == process.env.MASTERPASS) {
        console.log("Good.");
    }
} catch (e) {
    console.log(e);
}

promtShell.js -


const inquirer = require('inquirer');

module.exports.prompt = function (question) {
    const shellInput = inquirer.createPromptModule();
    let ans;

    shellInput(question)
        .then(anss => {
            ans = anss;
        })
        .catch(e => {
            console.log(e);
        })

    return ans;
}

questions.js -

module.exports = {
    mpq: "Plz enter the mater password: "
}

ManavGhaiCode avatar Mar 29 '22 09:03 ManavGhaiCode

Could you paste the error trace as is?

SBoudrias avatar Mar 29 '22 18:03 SBoudrias

TypeError: Cannot read property 'pipe' of undefined at PromptUI.run (/home/manav/code/password-manager/node_modules/inquirer/lib/ui/prompt.js:46:24) at promptModule (/home/manav/code/password-manager/node_modules/inquirer/lib/inquirer.js:33:24) at module.exports.prompt (/home/manav/code/password-manager/utils/promtShell.js:7:5) at Object. (/home/manav/code/password-manager/index.js:7:14) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)

ManavGhaiCode avatar Mar 30 '22 02:03 ManavGhaiCode