当前位置:网站首页>使用express-jwt第三方包报错TypeError: expressJWT is not a function
使用express-jwt第三方包报错TypeError: expressJWT is not a function
2022-08-04 05:26:00 【strongest强】
原因:你很有可能是安装了最新版本的express-jwt包,但是你使用的是第六版的语法
//第六版语法
const expressJWT = require("express-jwt");
const secretKey = "strongest ^0^";
app.use(
expressJWT({
secret: secretKey, algorithms: ["HS256"] })
);
//结果:express().use(expressJWT({ secret: secretKey, algorithms: ["HS256"] }));
//TypeError: expressJWT is not a function
解决方案
//最新语法
var {
expressjwt: expressJWT} = require("express-jwt");
const secretKey = "strongest ^0^";
app.use(
expressJWT({
secret: secretKey, algorithms: ["HS256"] })
);
express-jwt包更多详细内容,请看express-jwt官网
边栏推荐
猜你喜欢

The difference between px, em, and rem

3面头条,花7天整理了面试题和学习笔记,已正式入职半个月

解决安装nbextensions后使用Jupyter Notebook时出现template_paths相关错误的问题

字节最爱问的智力题,你会几道?

自动化测试的成本高效果差,那么自动化测试的意义在哪呢?

The idea setting recognizes the .sql file type and other file types

Cannot read properties of null (reading ‘insertBefore‘)

腾讯136道高级岗面试题:多线程+算法+Redis+JVM

程序员也应了解的Unity粒子系统

利用Jenkins实现Unity自动化构建
随机推荐
程序员也应了解的Unity粒子系统
The string class introduction
DP4398:国产兼容替代CS4398立体声24位/192kHz音频解码芯片
读者让我总结一波 redis 面试题,现在肝出来了
处理List<Map<String, String>>类型
Embedded system driver primary [3] - _IO model in character device driver foundation
npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa
Do you think border-radius is just rounded corners?【Various angles】
TensorRTx-YOLOv5工程解读(一)
JS基础--强制类型转换(易错点,自用)
Oracle备份脚本
高性能高可靠性高扩展性分布式防火墙架构
7.18 Day23----标记语言
JNI基本使用
C语言 -- 操作符详解
将自定义类型作为关联容器的key
MySQL log articles, binlog log of MySQL log, detailed explanation of binlog log
【论文阅读笔记】无监督行人重识别中的采样策略
12、分页插件
部署LVS-DR群集【实验】