【nodejs】TypeError: expressJwt is not a function

There may be the following reasons for the "expressJwt is not a function" message:

  1. The express-jwt module is not installed. Before using express-jwt, you need to install this module first. It can be installed with the following command:
npm install express-jwt --save
  1. Import error. If the wrong module or object is imported in the code, the "expressJwt is not a function" error will also appear. Please ensure that the express-jwt module and related functions and objects are imported correctly.

  2. Versions are not compatible. If you are using an older Express version, there may be an incompatibility with express-jwt. Please make sure your Express version is compatible with express-jwt.

  3. Configuration error. When using express-jwt, keys and other options need to be configured correctly. If the configuration is wrong, it will also cause the "expressJwt is not a function" error. Please check your configuration is correct.

analyze:

It is possible that the Express version and the express-jwt version are not compatible, because both versions are installed with the latest version, and this problem is likely to occur. By trying to modify the version and solving the error problem.
The modified version is attached below:

"express": "^4.17.1",
 "express-jwt": "^5.3.3",
 "jsonwebtoken": "^8.5.1",

Guess you like

Origin blog.csdn.net/qq_37609787/article/details/131417233