Error with discord.js?

Hey I run a discord bot when all of a sudden 2 weeks ago it threw this error

internal/modules/cjs/loader.js:550

11:11 PM

throw err;

11:11 PM

^

11:11 PM11:11 PM

Error: Cannot find module ‘ws’

11:11 PM

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

I tried updating my NPM with npm install but i get this error

npm WARN deprecated snekfetch@3.6.4: use node-fetch instead
npm WARN checkPermissions Missing write access to /app/node_modules/@discordjs
npm WARN discord.js@11.5.1 requires a peer of erlpack@discordapp/erlpack but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of libsodium-wrappers@^0.7.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of node-opus@^0.2.7 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of sodium@^2.0.3 but none is installed. You must install peer dependencies yourself.
npm WARN discord.js@11.5.1 requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.
npm WARN Lyras-Companion@2.3.1 No description
npm WARN Lyras-Companion@2.3.1 No repository field.
npm WARN Lyras-Companion@2.3.1 No license field.

npm ERR! path /app/node_modules/@discordjs
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access ‘/app/node_modules/@discordjs
npm ERR! { Error: EACCES: permission denied, access ‘/app/node_modules/@discordjs
npm ERR! stack: ‘Error: EACCES: permission denied, access ‘/app/node_modules/@discordjs’’,
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘access’,
npm ERR! path: ‘/app/node_modules/@discordjs’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

Yes i’ve tried running it with “sudo” infront of it. Its annoying because this bot handles all the admin work in my server…

Try to run this commands in your project console. I think is because you have disabled pnpm

enable-pnpm
pnpm install
pnpm install ws

The error I see is that you don’t have installed ws module.

The others are warnings, but first try to fix the first thing to see if that is the whole problem.

Also you have a warning for use snekfetch and npm recommends to use node-fetch module.
Look here

1 Like

That enable-pnpm did the trick thank you :smiley: its so tedious when you get internal issues like this.