Yeoman - 在循环依赖中访问模块导出的不存在属性____

Posted

技术标签:

【中文标题】Yeoman - 在循环依赖中访问模块导出的不存在属性____【英文标题】:Yeoman - Accessing non-existent property ____ of module exports inside circular dependency 【发布时间】:2021-02-13 18:53:06 【问题描述】:

哟! 我正在尝试yeoman,我正在制作一个测试生成器,但正如我在this issue 中报告的那样,有一个小问题。

这是我的代码:

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(" + "))
    
;

基本上,它应该直接提示我这些问题。但在此之前,我遇到了很多错误。

问题前的输出如下所示:

(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

我想知道它为什么这样做。

提前感谢您的帮助!

【问题讨论】:

【参考方案1】:

警告来自节点 v14.x.x 我也不知道为什么节点作者会这样设计。 现在,我只需将节点版本从 v14.x 切换到 v12.x 或 v13.x,警告就会消失。

【讨论】:

以上是关于Yeoman - 在循环依赖中访问模块导出的不存在属性____的主要内容,如果未能解决你的问题,请参考以下文章

错误:警告:在循环依赖中访问模块导出的不存在属性“findOne”

(节点:15867)警告:在循环依赖中访问模块导出的不存在属性“cat”

(节点:52213)警告:在循环依赖中访问模块导出的不存在属性“MongoError”(使用节点--trace-warnings

节点模块导出,访问不存在的属性错误,Jasmine

从另一个提供循环依赖的模块打开活动

ReactNative进阶(三十二):前端构建工具--Yeoman