Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

197
Views
Mongoose this.module.instantiate();

I made a test autorole command with mongodb, but when I tried to run it, I encountered an error. Here are my codes:

Schema

import mongoose from"mongoose"

const roleSchema = new mongoose.Schema({
    Role: {
       type: String,
       unique: true,
       required: true,
     },
    GuildID: {
       type: String,
       unique: true,
       required: true,
     },
});

const roleModel = module.exports = mongoose.model("autorole", roleSchema)

Event

import RoleData from "../schemas/autorole.js";

module.exports = async (member) => {
    const data = await roleData
      .findOne({
        GuildID: member.guild.id,
      })
      .catch((err) => console.log(err));
  
    if (data) {
      let role = data.Role;
      let arole = member.guild.roles.cache.get(role);
      if (role) {
        member.roles.add(arole);
      } else if (!role) {
        return;
      }
    } else if (!data) {
      return;
    }
  };

the error it gave

node:internal/modules/esm/module_job:128
        this.module.instantiate();
                    ^
Error: request for '../schemas/autorole.js' is not in cache
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:409:24)
    at async file:///home/alperen/bots/ubuntu-achela-yedek/src/app.js:21:27 {
  code: 'ERR_VM_MODULE_LINK_FAILURE'
}

Is there an error in the command or is it some other problem?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!