jaydenseric / graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 131 forks source link

Cant require Upload and graphqlUploadExpress #324

Closed TolgaYld closed 2 years ago

TolgaYld commented 2 years ago

Hi,

firstly sorry i think it will be a duplicate but i cant fix the error.

this was my old "import" const { graphqlUploadExpress, Upload } = require('graphql-upload');

now i write:

const Upload = require('graphql-upload/Upload');
const graphqlUploadExpress = require('graphql-upload/graphqlUploadExpress');

and i still get this error:

"Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './Upload' is not defined by "exports" in /Users/user/Desktop/App/dummys/node/project/node_modules/graphql-upload/package.json"

How can i fix this?

thanks in advance :)

jaydenseric commented 2 years ago

You need to specify the full file name with the file extension:

const graphqlUploadExpress = require("graphql-upload/graphqlUploadExpress.js");

I'm not sure why you want to require the Upload class, as that is more of an implementation detail. If you want to get the TypeScript type for what the Upload scalar resolves, you can do it this way for JSDoc based types:

/** @type {import("graphql-upload/processRequest.js").FileUpload} */

Or this way in TypeScript (assuming you have the right TypeScript project config):

import type { FileUpload } from "graphql-upload/processRequest.js";

Hope that helps!

ZobairQ commented 1 year ago

this is still an issue.. even with const graphqlUploadExpress = require("graphql-upload/graphqlUploadExpress.js"); it is not working

Miguel-Leite commented 1 year ago

I'm having problems using graphql-upload. Does anyone have the solution?

sebastianFast commented 1 year ago

const { graphqlUploadExpress } = require("graphql-upload");

Worked yesterday and today it doesnt;

No "exports" main defined in ....

owali-softic commented 1 year ago

const { graphqlUploadExpress } = require("graphql-upload");

cannot find this, there is conflict with "express-graphql": "^0.12.0", "graphql": "^15.8.0", version. How can I solve this

great-ian commented 1 year ago

It seems still not worked. Any Ideas? ( "graphql-upload": "^13.0.0",)

Error message : Package subpath './graphqlUploadExpress.js' is not defined by "exports" in

Maxcrazy1 commented 1 year ago

Error: Package subpath './graphqlUploadExpress' is not defined by "exports".

This bug still exists! 😿😿

great-ian commented 1 year ago

@Maxcrazy1 I had to downgrade all the packages related to graphql-upload. For some unknown reason, it just started to work after that.

Here's a portion of my code for your reference:

app.module.ts import { graphqlUploadExpress } from 'graphql-upload';

...

export class AppModule implements NestModule { configure(consumer: MiddlewareConsumer) { consumer .apply(graphqlUploadExpress()) .forRoutes("graphql") } }

And it worked.

For package.json, here are the related dependencies:

In dependencies:

"graphql-upload": "^13.0.0",

in devDependencies: "@types/graphql-upload": "^8.0.11",

Take a look and see if you could find anything useful.