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

311
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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