0

I am learning to use middlewares and as I am trying to import express-jwt it does not work. I am using the following syntax: const expressJwt = require('express-jwt')

I uninstalled express-jwt and installed an older version express-jwt@5.3.1, in which it works, but I wanna know how to fix it on the new version.

NeNaD
  • 18,172
  • 8
  • 47
  • 89
  • Does this answer your question? [import error when trying to import express-jwt](https://stackoverflow.com/questions/72212398/import-error-when-trying-to-import-express-jwt) – Fiehra Oct 05 '22 at 20:57

2 Answers2

1

Try this:

const { expressjwt } = require("express-jwt");

Official docs

NeNaD
  • 18,172
  • 8
  • 47
  • 89
0
//protection API and Authentication JWT middleware

const expressJwt = require('express-jwt')

function authJwt() {
    const secret = process.env.secret;

    function expressJwt(param) {
        return undefined;
    }
have the same problem


    return expressJwt({
      secret,
       algorithms: ['HS256']
  })
 }

 module.exports = authJwt;

enter image description here

Pradeep Kumar
  • 1,193
  • 1
  • 9
  • 21
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/33181863) – possum Nov 20 '22 at 16:29