0
votes

After adding 'ytdl-core' to node_module in files. I tried to use it for a discord bot by requiring (const ytd1 = require('ytd1-core');) but it errors and does this:

module.js:538
    throw err;
    ^

Error: Cannot find module 'ytd1-core'
    at Function.Module._resolveFilename (module.js:536:15)
    at Function.Module._load (module.js:466:25)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\David\Documents\Discord Bot\discordbot.js:14:14)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)

I tried looking up fixes, in my terminal I used npm install ytdl-core, yarn add ytdl-core and nothing happened. The folder does exist with no pop up error.

The bot can find the discord.js file in the node_module but not ytdl-core. I don't know if it didn't install right, if I have to do something manually, or make it a global file.

3
If you look closely you have "ytd1", not "ytdl"Antony

3 Answers

1
votes

As @Antony mentioned, I think you've made a typo error. There is no library called ytd1-core. Update your require with:

const ytdl = require('ytdl-core');
0
votes

Try installing ytdl package with npm i ytdl-core.

0
votes

You wrote const ytd1 = require('ytd1-core') but that package doesn't exists. You need to install the package called 'ytdl-core'. Then you need to require the package with const ytd1 = require('ytdl-core')