Search code examples
node.jsrequire

NodeJS: Error: Cannot find module 'ytdl-core'


I was creating a discord music bot in NodeJS, with discord.js as well, but whenever I run it, I get this error: (the file is not named module.js)

module.js:549
    throw err;
    ^

Error: Cannot find module 'ytdl-core'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module.__load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\Matthew\Desktop\discord bot\bot.js:2:12)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

At first, I thought it was because I needed to npm install the module like I did with discord.js, but instead I got the same error.


Solution

  • You require but don't install ytdl-core.

    Please install it with command :

    npm install ytdl-core
    

    or install with yarn:

    yarn add ytdl-core