title: Module.exports and require confusion
body: <p>I am taking Stephen Grinders MERN course on Udemy. There are three files in the course. My understanding of node modules is that it runs independently, which is why we need to import everything that the module needs inside the module. My question is:</p>
  
  <p>Why is it that in authRoutes.js file we do not need to import the passport.js file? We are using passport.authenticate function is authRoutes.js file it is not configured in the module.</p>
  
  <p><strong>index.js</strong></p>
  
  <pre><code>const express = require('express');
  require('./services/passport')
  const app = express();
  
  require('./Routes/authRoutes')(app);
  
  
  const PORT = process.env.PORT || 3000;
  app.listen(PORT);
  </code></pre>
  
  <p><strong>passport.js</strong></p>
  
  <pre><code>const passport = require('passport');
  const GoogleStrategy = require('passport-google-oauth20').Strategy;
  const keys=require('../config/keys')
  
  passport.use(new GoogleStrategy(
      {
      clientID:keys.googleClientID,
      clientSecret:keys.googleClientSecret,
      callbackURL:'/auth/google/callback'
  },(accessToken,refreshToken,profile,done)=&gt;{
      console.log(`${accessToken}, ${refreshToken}, ${profile.displayName}`)
  }
  ));
  </code></pre>
  
  <p>and </p>
  
  <p><strong>authRoutes.js</strong></p>
  
  <pre><code>const passport = require('passport');
  
  module.exports=app=&gt;{
      app.get('/auth/google',passport.authenticate('google',{
          scope:['profile','email']
      }))
  
      app.get('/auth/google/callback',passport.authenticate('google'))
  
  }
  </code></pre>