Node-Media-Server 安装模块后运行报错 TypeError: NodeMediaServer is not a constructor解决方案
这几天发现Node-Media-Server官方更新到了1.5.0。导致部分同学安装模块后运行的时候会报错。错误如下:
TypeError: NodeMediaServer is not a constructor
解决方案:
1、把引入方式 { NodeMediaServer } 改为 NodeMediaServer 即可如下:
把
const { NodeMediaServer } = require('node-media-server');
改为
const NodeMediaServer = require('node-media-server');
即可解决
2、修改成老版本1.4.14 重新安装依赖
引入模块的方式也是老方式 : const { NodeMediaServer } = require(‘node-media-server’);
"dependencies": {
"art-template": "^4.12.2",
"koa": "^2.5.0",
"koa-art-template": "^1.1.1",
"koa-bodyparser": "^4.2.0",
"koa-multer": "^1.0.2",
"koa-router": "^7.4.0",
"koa-session": "^5.8.1",
"koa-static": "^4.0.2",
"md5": "^2.2.1",
"mongodb": "^3.0.4",
"mz-modules": "^2.1.0",
"node-media-server": "1.4.14",
"silly-datetime": "^0.1.2",
"svg-captcha": "^1.3.11"
}
官方文档:https://github.com/illuspas/Node-Media-Server/issues/184