question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"undefined is not a function" on jwt.sign

See original GitHub issue

Code:

jwt = require('express-jwt'),
var token = jwt.sign( { id: user._id }, secret.secretToken, { expireInMinutes: tokenManager.TOKEN_EXPIRATION } )

Error:

        var token = jwt.sign( { id: user._id }, secret.secretToken, { expireInMinut
                        ^
TypeError: undefined is not a function

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
acushlakonceptcommented, Apr 29, 2022

This fix the issue for me. const { expressjwt: jwt } = require("express-jwt");

4reactions
subpopularcommented, Aug 5, 2015

Seems you could just as easily export the sign method from the already included jsonwebtoken module so that this module could provide that, no?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: jwt.sign is not a function - Stack Overflow
When I enter john.doe and foobar in a form, I get told by console that jwt.sign is not a function, even after an...
Read more >
[Solved]-TypeError: jwt.sign is not a function-node.js
Coding example for the question TypeError: jwt.sign is not a function-node.js.
Read more >
Implementing JWT Authentication in Node.js
In this post, we will learn how to implement JWT (JSON Web Token) based authentication in Node.js, and build a complete server application ......
Read more >
Node.js Express: JWT example | Token Based Authentication ...
To process Authentication & Authorization, we have these functions: - check if token is provided, legal or not. We get token from x-access-token...
Read more >
ReferenceError: jwt is not defined(jsonwebtoken error)
const token= jwt. sign ({ ^ ReferenceError: jwt is not defined at D:\programming\nodejs\expressjs\routerHandler\userHandler.js:49:30 [nodemon] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found