javascriptnode.jsmoduleyeomanyo

Yeoman - Accessing non-existent property ____ of module exports inside circular dependency


Yo! I am trying yeoman and I'm making a test generator, but as I reported in this issue, there is a small problem.

Here is my code:

const Generator = require('yeoman-generator');

module.exports = class extends Generator {
    // The name `constructor` is important here
    constructor(args, opts) {
        // Calling the super constructor is important so our generator is correctly set up
        super(args, opts);

        // Next, add your custom code
        this.argument("appname", {type: String, required: false});
    }

    async prompting(){
        const answers = await this.prompt([
            {
                type: "input",
                name: "name",
                message: "Your project name",
                default: this.appname
            },
            {
                type: "confirm",
                name: "cool",
                message: "Would you like to enable the Cool Feature?"
            },
            {
                type: "list",
                name: "features",
                message: "What do you want to make today?",
                choices: [
                    "Some tests",
                    "Other tests, why not!",
                    "Another test?",
                    "Yes."
                ]
            },
            {
                type: "checkbox",
                name: "more",
                message: "Anything more?",
                choices: [
                    {
                        name: "I'm a bit bored",
                        value: "bored",
                        checked: true
                    },
                    {
                        name: "I'm busy doing something else.",
                        value: "smthelse",
                        checked: false
                    }
                ]
            }
        ]);
        this.log("app name", answers.name);
        this.log("cool feature", answers.cool);
        this.log("feature", answers.features);
        this.log("more", answers.more.join(" + "))
    }
};

Basically, it should've prompted me directly the questions. But before, I get lots of errors.

The output before the questions looks like this:

(node:35760) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:35760) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:35760) Warning: Accessing non-existent property 'which' of module exports inside circular dependency

And I wonder why it's doing this.

Thanks in advance for your help!


Solution

  • The warnings come from node v14.x.x I also don't know why the node author design in this way. Now, I just switch node version from v14.x to v12.x or v13.x, and the warnings disappear.