• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

181
Vistas
IntelliSense not working for dynamically loaded JavaScript files

I have created number of models(separate files) in my NodeJS Project. I am exporting all the files dynamically in single index.js file. Now when I require models folder and try to load the Model Intellisense is not be able to load that Model.

  • Expected result

enter image description here

  • Current result

enter image description here

  • Is there any solution to resolve this issue. /models/index.js
'use strict';

const testFolder = './app/models';
const fs = require('fs');
const commons = require('../common');

const ExportsModel = {};
fs.readdirSync(testFolder).forEach((file) => {
  const fileName = file.split('.')[0];
 if (fileName !== 'index') ExportsModel[commons.capitalizeFirstLetter(fileName) + 'Conrtroller'] = require(`./${fileName}`);
});

// console.info('ExportsModel', ExportsModel);
module.exports = ExportsModel;

/models/station.js

const mongoose = require('../configs/db.configs');
const Schema = mongoose.Schema;

const ModelSchema = new Schema(
  {
    name: { type: String, required: true },
    stationId: { type: Schema.Types.ObjectId, ref: 'station', required: true },
    description: { type: String, required: true },
  },
  { timestamps: true }
);

module.exports = mongoose.model('charger', ModelSchema);

Thank you in advance

almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda