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

No "exports" main defined "\node_modules\graphql-upload\package.json" #333

Closed
nekmart opened this issue Aug 25, 2022 · 1 comment
Closed

Comments

@nekmart
Copy link

nekmart commented Aug 25, 2022

Hello, I am building a nestjs project with typescript and graphql. I want to use graphql-upload in my project.

I install two package-

  1. graphql-upload
  2. @types/graphql-upload

After installing this packages. I import it-

import { GraphQLUpload, FileUpload } from "graphql-upload";

And my Mutation-

@Mutation(() => SuccessInfo, { name: "addBrand" })
@Roles(Role.MODERATOR, Role.ADMIN)
@UseGuards(AuthGuard, RolesGuard)
add(
    @Args("brandInput") brandInput: BrandInput,
    @Args('file', { type: () => GraphQLUpload }) file: FileUpload,
) {
    return this.brandService.add(brandInput);
}

Here I am getting this error-
Screenshot 2022-08-25 225447

I see this issue alreay- #305

From this issue I am trying to use-

import GraphQLUpload from "graphql-upload/GraphQLUpload.js";

But here I am getting typescript type declaration error like this image-
Screenshot (5)

How can I solve this issue.

@jaydenseric
Copy link
Owner

In the readme exports section:

https://github.com/jaydenseric/graphql-upload#exports

Screen Shot 2022-08-26 at 8 01 48 am

You can see the module is documented as GraphQLUpload.mjs.

If you just look at the modules that are published:

https://unpkg.com/browse/graphql-upload@16.0.1/

Screen Shot 2022-08-26 at 8 03 01 am

You can see the module really is called GraphQLUpload.mjs.

So why are you attempting this, with .js instead of the correct .mjs?

import GraphQLUpload from "graphql-upload/GraphQLUpload.js";

Even if you were importing correctly, it seems Nest.js doesn't support importing standard JavaScript modules anyway so you will probably run into that soon, see #332 (comment) . If you do run into that issue, please raise it with Nest.js not here.

@jaydenseric jaydenseric closed this as not planned Won't fix, can't repro, duplicate, stale Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants