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

313
Views
NPM Passport Strategy LINKED Cannot find module

I have created a custom private passport strategy in a separate module called passport-x I did

npm link .

in that project directory and

npm link passport-x

in the consuming project.

In my passport.js file, I have

var LocalStrategy = require('passport-local').Strategy;
var XStrategy = require('passport-X').Strategy;
..
module.exports = function(passport) {
      passport.use('local-signup', new LocalStrategy({
      ....

      passport.use('x-login', new XStrategy({
      ....

However, I am getting this error

Error: Cannot find module 'passport-x'

despite the fact I can see passport-x in my node_modules in the consuming project.

Anything perhaps I am not aware about when using more than 1 strategy at the same time or using custom strategies?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The problem was to do with the structure of the lib folder I was importing... I had used

lib/
  moduleX/
       index.js
       strategy.js

when it was looking for an index.js in the lib directory itself:

lib/
    index.js
    strategy.js

The presence of an index.js file allows you to do this in the consuming code:

var XStrategy = require('passport-X').Strategy; 
over 4 years ago · Santiago Trujillo Report
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!