首页 > 解决方案 > 为什么我已经安装了错误查找模块

问题描述

我正在尝试编写一个不和谐的音乐机器人,这是我的代码:

const config = require('config.json')
const Discord = require('discord.js');
const ffmpeg = require('ffmpeg-extra')
const client = new Discord.Client();

client.once('ready', () => {
    console.log('Ready!');
});
client.on('message', message => {
    if(message.content.toLocaleLowerCase() === "elevator"){
        if(message.member.voice.channel){
            message.channel.send("Thanks to https://www.bensound.com for supplying us with this music.")
            play(message.member.voice.channel)
        }
        else {
            message.channel.send("Yo, please join a VC first.")
        }
    }
});

async function play(voiceChannel) {
    const connection = await voiceChannel.join();
    connection.play('elevator.mp3');
}

client.login(config.token);

出于某种原因,即使我通过 npm install ffmpeg 安装了 ffmpeg,它也会说:

Error: Cannot find module 'ffmpeg-extra'

编辑:当我使用 const ffmpeg = require("ffmpeg") 我得到这个错误:

UnhandledPromiseRejectionWarning: Error: FFmpeg/avconv not found!

标签: javascriptnode.jsnpmffmpeg

解决方案


我认为你需要错误的包。

ffmpeg-extra不是公共包。

ffmpeg存在于此

extra-ffmpeg存在于此

也许您必须要求这两个软件包之一。


推荐阅读