我正在使用mediasoup库与一个房间中的许多人创建视频通话。导入npm包后,它给了我一个未定义的消息:
async createWorker() {
this.worker = await mediasoup.createWorker({
rtcMinPort: 2000,
rtcMaxPort: 2080,
});
logger.debug(`worker pid ${this.worker.pid}`);
this.worker.on("died", (error: any) => {
// This implies something serious happened, so kill the application
logger.error({
error: error.toString()
}, "mediasoup worker has died");
setTimeout(() => process.exit(1), 2000); // exit in 2 seconds
});
字符串
}
错误:
C:\Users\andri\Desktop\resume_projects\college_chat\back\src\messaging\socketManager\index.ts:22
this.worker = await mediasoup.createWorker({
^
TypeError: Cannot read properties of undefined (reading 'createWorker')
at SocketManager.<anonymous> (C:\Users\andri\Desktop\resume_projects\college_chat\back\src\messaging\socketManager\index.ts:22:35)
at Generator.next (<anonymous>)
at C:\Users\andri\Desktop\resume_projects\college_chat\back\src\messaging\socketManager\index.ts:31:71
at new Promise (<anonymous>)
at __awaiter (C:\Users\andri\Desktop\resume_projects\college_chat\back\src\messaging\socketManager\index.ts:27:12)
at SocketManager.createWorker (C:\Users\andri\Desktop\resume_projects\college_chat\back\src\messaging\socketManager\index.ts:47:16)
at SocketManager.<anonymous> (C:\Users\andri\Desktop\resume_projects\college_chat\back\src\messaging\socketManager\index.ts:123:16)
at Generator.next (<anonymous>)
at C:\Users\andri\Desktop\resume_projects\college_chat\back\src\messaging\socketManager\index.ts:31:71
at new Promise (<anonymous>)
型
我的节点版本:v18.17.0我的python版本:3.10.7我已经安装了MSBuild工具,因为我的笔记本电脑上有Visual Studio(我在Windows上)。我也试图从一个单独的终端安装此软件包作为管理员-没有工作。
1条答案
按热度按时间l7mqbcuq1#
mediasoup在这里是通过其默认值导入的,当它不导出默认值(未定义)时。MediaWorker被定义为命名导出。您可以将所有命名导出作为变量
import * as mediasoup
导入,也可以仅导入MediaWorkerimport {createWorker}
。该软件包已成功安装,因为如果您导入的是无效的软件包,则会引发“Cannot find module”错误。