Cannot Find Module

Error -


    throw err;


Error: Cannot find module 'ytdl-core'

Require stack:

- /app/index.js

    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:713:15)

    at Function.Module._load (internal/modules/cjs/loader.js:618:27)

    at Module.require (internal/modules/cjs/loader.js:771:19)

    at require (internal/modules/cjs/helpers.js:68:18)

at Object.<anonymous> (/app/index.js:17:14)

    at Module._compile (internal/modules/cjs/loader.js:868:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:879:10)

    at Module.load (internal/modules/cjs/loader.js:731:32)

    at Function.Module._load (internal/modules/cjs/loader.js:644:12)

    at Function.Module.runMain (internal/modules/cjs/loader.js:931:10) {


Tried enable-npm and npm i but still didn’t work.

Project name is rk-discord

Thanks! :slight_smile:

Have you tried npm install ytdl-core ?

Yes, I have. Any other suggestions?

Let’s try with yarn => yarn add ytdl-core

If it still you get the error make sure you have this written in your code:
var ytdlCore = require("ytdl-core");

-su yarn: command not found

I dont need ytdl anymore -

Issue is - I’ve removed it, but now its saying it cant find another module (SQLite I think)

Anyone know whats going on here?

you can try adding modules manually in package.json. it’s the preferable way to install them.

1 Like

Yep, already tried that

Hey @ScottHJStenkilsson I’m pretty sure your problem here is that you’re listing Node as a dependency. That creates a recursive problem with pnpm’s install process that means that Glitch has a hard time finding the modules where they’re expected to be.

You can remove Node from your dependency list and that should resolve the issue. If you require Node v12 you can set the value for node in the engines stanza to 12.x and we’ll use that version for your project.

Hope this helps!

1 Like

Yeah, according to @cori, your problem is lied in the line 31

"node": "^12.8.1",

Remove it and replace the line 10-12 to this:

"engines": {
    "node": "12.8.1"

Btw, I think the Add Package feature should remove/hide the node from its list. It causes misunderstand for the package.json.

1 Like

We rely directly on the API for the Add Packages functionality, but I agree it makes sense not to have node in that list. Thanks for pointing that out, @dangtu!


Did that, still getting ‘cannot find module’

Getting more errors now! Anyone help?

Could you please invite me to your project and I will be happy to help you solve all problems you are currently experiencing!

You can invite me privately by clicking my user icon => “message”

Getting new and more errors mean it is a good news. We get some process. Can you share the new errors plz?

@CallumOKane I don’t have invitation but I have the project link:!/rk-discord

New update:
Maybe your problem lies in fs module. That module is not exist. It is a placeholder in npm. But you use it so it very likey it would cause an error. Anyway, please check your dependencies and make sure no built-in packages were added.

Your error was something to do with the version of node you were using, so I lowered it to version: 10.15.3.

Then another error started appearing: Error: Cannot find module '../build/better_sqlite3.node'Which I simply fixed by doing rm -rf shrinkwrap.yaml && enable-pnpm

Your bot has started up fine now and I do not see any other problems!

Happy Glitching!


I think I had the same issue and all it needed was the enable-pnpm command. That was my initial thought when I read he tried with enalbe-npm instead.

Thank You, It Worked With Me

1 Like