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?
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;