Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

98
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda