Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

97
Vistas
Does way of Extending Module in Node.js change?

I am trying to follow the tutorial at the following link about extending modules in JS. https://www.guru99.com/node-js-modules-create-publish.html and the codes are

Tutorial.js

var exports=module.exports={};
exports.tutorial=function()
{
console.log("Guru99 Tutorial")
}

NodeTutorial.js

var Tutor=require('./Tutorial.js');
exports.NodeTutorial=function()
{
console.log("Node Tutorial")
function pTutor()
{
var PTutor=Tutor
PTutor.tutorial();
}
}

App.JS

var localTutor=require('./NodeTutorial.js');
localTutor.NodeTutorial();
localTutor.NodeTutorial.pTutor();

it give the error of

localTutor.NodeTutorial.pTutor(); is not a function

so I searched at this forum and found this same code syntax with same issue Extending Module in nodejs gives error and according to the answer, I changed the code to

this.pTutor = function(){
var PTutor=Tutor
PTutor.tutorial();
}

and

var localTutor = new require('./NodeTutorial.js');
localTutor.NodeTutorial();
localTutor.pTutor();

so what I would like to ask is the syntax of extending modules change or what is the problem here? Is the way from tutorial no longer work?

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda