This is the first time I am using JSON Web Tokens. But the error is coming, and the error is expressjwt is not a function.
const expressjwt = require("express-jwt")
const config = require('../../nodemon.json')
function jwt() {
const { secret } = config
return expressjwt({ secret, algorithm: ["RS256", "HS256"] }).unless({
path: [
//public routes that don't require authentication
"users/authenticate"
]
})
}
module.exports = jwt;
TypeError: expressjwt is not a function
at jwt (D:\jwt-implementation\routes\config\jwt.js:8:12)
at Object.<anonymous> (D:\jwt-implementation\app.js:26:9)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (D:\jwt-implementation\bin\www:7:11)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
[nodemon] app crashed - waiting for file changes before starting...