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

95
Views
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
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!