在PebbleHost部署Discord音乐机器人遇@discordjs/opus模块缺失问题求助
在PebbleHost部署Discord音乐机器人的Opus模块缺失问题
我正尝试在PebbleHost平台部署一款Discord音乐机器人(项目:discord-music-24-7),但每次启动都会触发模块缺失错误。已经通过平台内置包管理器安装了@discordjs/opus,也试过重新安装、降级该包,但问题依旧。
错误日志
15.11 21:29:21 [Bot] discord-music-24-7@4.2.1 start 15.11 21:29:21 [Bot] node ./src/app.js 15.11 21:29:23 [Bot] (8:29:23 PM) - [[INFO]] - Registered Miscellaneous Commands (id: misc) command group. 15.11 21:29:23 [Bot] (8:29:23 PM) - [[INFO]] - Registered Player Commands (id: player) command group. 15.11 21:29:23 [Bot] (8:29:23 PM) - [[INFO]] - Registered help in Miscellaneous Commands. 15.11 21:29:23 [Bot] (8:29:23 PM) - [[INFO]] - Registered skip in Player Commands. 15.11 21:29:25 [Bot] (8:29:25 PM) - [[INFO]] - Refresh interval has been disabled. 15.11 21:29:25 [Bot] (8:29:25 PM) - [[INFO]] - Connected to Discord! - Ready. 15.11 21:29:25 [Bot] (8:29:25 PM) - [[INFO]] - Presence updated to: ◼ Nothing to play 15.11 21:29:25 [Bot] (8:29:25 PM) - [[INFO]] - Joined Chill Raum in Cocraft. 15.11 21:29:25 [Bot] (8:29:25 PM) - [[INFO]] - User EmoPlayer has joined Chill Raum. 15.11 21:29:25 [Bot] [WARN]: ytdl-core is out of date! Update with "npm install ytdl-core@latest". 15.11 21:29:28 [Bot] /node_modules/prism-media/src/util/loader.js:12 15.11 21:29:28 [Bot] throw new Error(errorLog.join('\\n')); 15.11 21:29:28 [Bot] ^ 15.11 21:29:28 [Bot] Error: Error: Cannot find module '/node_modules/@discordjs/opus/prebuild/node-v93-napi-v3-linux-x64-glibc-2.31/opus.node' 15.11 21:29:28 [Bot] Require stack: 15.11 21:29:28 [Bot] - /node_modules/@discordjs/opus/lib/index.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/util/loader.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/opus/Opus.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/opus/index.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/index.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/player/BasePlayer.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/player/BroadcastAudioPlayer.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/VoiceBroadcast.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/ClientVoiceManager.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/Client.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/index.js 15.11 21:29:28 [Bot] - /node_modules/@greencoast/discord.js-extended/dist/classes/ExtendedClient.js 15.11 21:29:28 [Bot] - /node_modules/@greencoast/discord.js-extended/dist/index.js 15.11 21:29:28 [Bot] - /src/app.js 15.11 21:29:28 [Bot] Error: Cannot find module 'node-opus' 15.11 21:29:28 [Bot] Require stack: 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/util/loader.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/opus/Opus.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/opus/index.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/index.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/player/BasePlayer.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/player/BroadcastAudioPlayer.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/VoiceBroadcast.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/ClientVoiceManager.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/Client.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/index.js 15.11 21:29:28 [Bot] - /node_modules/@greencoast/discord.js-extended/dist/classes/ExtendedClient.js 15.11 21:29:28 [Bot] - /node_modules/@greencoast/discord.js-extended/dist/index.js 15.11 21:29:28 [Bot] - /src/app.js 15.11 21:29:28 [Bot] Error: Cannot find module 'opusscript' 15.11 21:29:28 [Bot] Require stack: 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/util/loader.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/opus/Opus.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/opus/index.js 15.11 21:29:28 [Bot] - /node_modules/prism-media/src/index.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/player/BasePlayer.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/player/BroadcastAudioPlayer.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/VoiceBroadcast.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/voice/ClientVoiceManager.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/client/Client.js 15.11 21:29:28 [Bot] - /node_modules/discord.js/src/index.js 15.11 21:29:28 [Bot] - /node_modules/@greencoast/discord.js-extended/dist/classes/ExtendedClient.js 15.11 21:29:28 [Bot] - /node_modules/@greencoast/discord.js-extended/dist/index.js 15.11 21:29:28 [Bot] - /src/app.js 15.11 21:29:28 [Bot] at Object.loader [as require] (/node_modules/prism-media/src/util/loader.js:12:9) 15.11 21:29:28 [Bot] at loadOpus (/node_modules/prism-media/src/opus/Opus.js:17:17) 15.11 21:29:28 [Bot] at new OpusStream (/node_modules/prism-media/src/opus/Opus.js:46:10) 15.11 21:29:28 [Bot] at new Encoder (/node_modules/prism-media/src/opus/Opus.js:149:5) 15.11 21:29:28 [Bot] at AudioPlayer.playPCMStream (/node_modules/discord.js/src/client/voice/player/BasePlayer.js:58:34) 15.11 21:29:28 [Bot] at AudioPlayer.playUnknown (/node_modules/discord.js/src/client/voice/player/BasePlayer.js:53:17) 15.11 21:29:28 [Bot] at VoiceConnection.play (/node_modules/discord.js/src/client/voice/util/PlayInterface.js:71:28) 15.11 21:29:28 [Bot] at Player.play (/src/classes/Player.js:124:39) 15.11 21:29:28 [Bot] at runMicrotasks (<anonymous>) 15.11 21:29:28 [Bot] at processTicksAndRejections (node:internal/process/task_queues:96:5) 15.11 21:29:28 [PebbleHost] Server shut down (running) 15.11 21:29:28 [PebbleHost] Server stopped
解决方案
1. 彻底重置依赖并重新安装
通过PebbleHost控制台执行以下命令,清除旧依赖文件后重新下载适配环境的版本:
rm -rf node_modules package-lock.json npm install
2. 强制重新构建@discordjs/opus
针对服务器架构重新生成预编译的opus.node文件,解决路径不匹配问题:
npm rebuild @discordjs/opus --force
3. 安装备用Opus模块
如果@discordjs/opus仍无法正常工作,尝试安装兼容的替代模块:
- 安装node-opus:
npm install node-opus - 或者安装纯JS实现的opusscript(无需预编译,兼容性更强):
npm install opusscript
prism-media会自动检测并使用已安装的Opus模块。
4. 检查Node.js版本兼容性
确认PebbleHost服务器的Node.js版本为16.x或更高(项目v4.2.1的要求):
- 控制台执行
node -v查看版本,若版本过低,在PebbleHost面板切换到兼容版本。
5. 验证依赖安装状态
执行以下命令确认模块是否正确安装:
npm list @discordjs/opus
检查输出中是否存在报错或缺失项。
内容的提问来源于stack exchange,提问作者maxlol3265
相关产品推荐
相关产品推荐

