简体   繁体   English

TypeError: Class extends value undefined is not a constructor 或 null - Node.js

[英]TypeError: Class extends value undefined is not a constructor or null - Node.js

I try to use Clear in my index.js , but the code doesn't work, it extends the class Clear by Moderation to get Moderation method.我尝试在我的index.js中使用 Clear,但代码不起作用,它扩展了 class Clear by Moderation 以获取 Moderation 方法。

Full error:完整错误:

class Clear extends Moderation {
                    ^
TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (C:\Users\Chigu\SoftKr\Asuha-Discord-Universal-Bot\Src\Actions\Moderation\Commands\Clear.js:5:21)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (C:\Users\Chigu\SoftKr\Asuha-Discord-Universal-Bot\Src\Actions\Moderation\Moderation.js:2:17)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)

Process finished with exit code 1

Clear.js清除.js

const Discord = require("discord.js");
const {Moderation} = require("../Moderation");

class Clear extends Moderation {
    constructor(message, client) {
        super(message, client);
        this.command = "clear";
   } //methode and code
}

module.exports = {
    Clear
}

Moderation.js审核.js

const {Clear} = require("./Commands/Clear");

class Moderation {
    constructor(message, client, staff, prefix) {
        this.message = message;
        this.client = client;
        this.staff = staff;
        this.prefix = prefix;
    } //methode and code
}

module.exports = {
    Moderation,
}

Could it be a circular dependency issue?会不会是循环依赖问题? You're importing each class inside the other.您正在将每个 class 导入另一个内部。 Did you try removing this line from Moderation.js ?您是否尝试从Moderation.js中删除此行?

const {Clear} = require("./Commands/Clear");

I also encountered the same error and did what was said, but there was no solution.我也遇到了同样的错误,按照说的做了,但是没有解决办法。

Then I installed 16.14.0 LTS from nodejs releases and the problem was solved.然后我从 nodejs 版本安装了 16.14.0 LTS,问题就解决了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError: Class extends value 命令不是构造函数或 null - node.js - TypeError: Class extends value Command is not a constructor or null - node.js 类型错误:Class extends value undefined is not a constructor or null in react js - TypeError: Class extends value undefined is not a constructor or null in react js TypeError: Class extends value undefined is not a constructor 或 null - TypeError: Class extends value undefined is not a constructor or null React Class 中的“TypeError: Class extends value undefined is not a constructor or null”问题 - Issue with “TypeError: Class extends value undefined is not a constructor or null” in React Class 类型错误:在 MVC 作业中运行节点种子时,Class 扩展值未定义不是构造函数或 null - TypeError: Class extends value undefined is not a constructor or null when run node seeds in MVC homework TypeError: Class extends value undefined is not a constructor 或 null (svelte redis) - TypeError: Class extends value undefined is not a constructor or null (svelte redis) Nodemailer:未捕获类型错误:Class 扩展值未定义不是构造函数或 null - Nodemailer: Uncaught TypeError: Class extends value undefined is not a constructor or null REACT TypeError: Class extends value undefined is not a constructor or null - REACT TypeError: Class extends value undefined is not a constructor or null 反应TypeError:类扩展未定义的值不是构造函数或null - React TypeError: Class extends value undefined is not a constructor or null Reactjs TypeError:类扩展值未定义不是构造函数或空值 - Reactjs TypeError: Class extends value undefined is not a constructor or null
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM