Zlib-sync failed to resolve

Hi! So I'm trying to integrate discordjs into my Svelte application because I want the bot to send DMs to users on a button press, but I don't want it to actually have any commands. So I created this discordBot.js file as shown and then imported the sendDM() function on one of the pages:
import { getUser } from "$lib/supabase";
import { Client, GatewayIntentBits } from 'discord.js';

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildMembers,
    ],
});
client.login(import.meta.env.VITE_BOT_TOKEN);

export async function sendDirectDM(discordId, message) {
    const user = await client.users.fetch(discordId);
    await user.send(message);
}

export async function getUserIdFromUsername(username) {
    const user = await client.users.fetch({ username });
    return user.id;
}

export async function sendDM(userId, message) {
    const user = await getUser(userId);
    const discordId = await getUserIdFromUsername(user.discord);
    await sendDirectDM(discordId, message);
}


But when I open the page on the localhost which calls one of these functions, it gives me the following error:
Failed to resolve import "zlib-sync" from "node_modules/.vite/deps/discord__js.js?v=f1677f66". Does the file exist?
10:35:55 AM [vite] Internal server error: Failed to resolve import "zlib-sync" from "node_modules/.vite/deps/discord__js.js?v=f1677f66". Does the file exist?
  Plugin: vite:import-analysis
  File: /Users/x/x/node_modules/.vite/deps/discord__js.js?v=f1677f66:50929:65
  50927|      }
  50928|      __name(getInitialSendRateLimitState, "getInitialSendRateLimitState");


I'm not sure what the issue is, and guidance would be very helpful
Was this page helpful?