Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nextjs + @discordjs/core - Module not found: Can't resolve 'zlib-sync' #9695

Closed
anirkm opened this issue Jul 10, 2023 · 5 comments
Closed

Nextjs + @discordjs/core - Module not found: Can't resolve 'zlib-sync' #9695

anirkm opened this issue Jul 10, 2023 · 5 comments

Comments

@anirkm
Copy link

anirkm commented Jul 10, 2023

Which package is this bug report for?

discordjs/core

Issue description

I am currently encountering what appears to be an issue with Next.js while running a project with its latest version. After placing the code within an API route and then executing "npm run dev", I'm experiencing a module not found error.

Steps to reproduce are as follows:

  1. Set up a Next.js project using the latest version.
  2. Put the code within an API route.
  3. Run the command "npm run dev".

Upon following these steps, the stated module not found error shows Interestingly, when i do a manual installation of the package, webpack throws an additional error stating that it cannot compile.

Code sample

import { NextRequest, NextResponse } from "next/server";
import { REST } from "@discordjs/rest";
import { API } from "@discordjs/core";
import { getServerSession } from "next-auth";

export async function GET(req: NextRequest) {
  const session = await getServerSession();

  if (!session) {
    return NextResponse.json({ error: "invalid session" }, { status: 401 });
  }

  const discordRest = new REST({ version: "10" }).setToken(process.env.DISCORD_TOKEN!);
  const discordApi = new API(discordRest);

  console.log(discordApi);

  return NextResponse.json({ session: session });
}

Versions

"@discordjs/core": "^0.6.0",
"next": "13.4.9",

nodejs : v18.12.1

Issue priority

Low (slightly annoying)

Which partials do you have configured?

Not applicable

Which gateway intents are you subscribing to?

Not applicable

I have tested this issue on a development release

No response

@suneettipirneni
Copy link
Member

Try importing from @discordjs/core/http-only and see if that works.

@anirkm
Copy link
Author

anirkm commented Jul 10, 2023

Try importing from @discordjs/core/http-only and see if that works.

image
do i need to install a canary version or something ?

@suneettipirneni
Copy link
Member

It might a typescript quirk, but if you’re on the latest version that import should work. Try ignoring the error and running it.

@vladfrangu
Copy link
Member

Not a Typescript quirk, you'll need to set moduleResolution to node16 in your tsconfig.json

@anirkm
Copy link
Author

anirkm commented Jul 10, 2023

It might a typescript quirk, but if you’re on the latest version that import should work. Try ignoring the error and running it.

did a //@ts-ignore and it worked ! thanks

@Jiralite Jiralite closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants