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 132 forks source link

Error: No "exports" main defined in /Volumes/Personal/code-work/node-projects/office/pf-node-backend/node_modules/graphql-upload/package.json #371

Closed aoneahsan closed 1 year ago

aoneahsan commented 1 year ago

Error: No "exports" main defined in /Volumes/Personal/code-work/node-projects/office/pf-node-backend/node_modules/graphql-upload/package.json

I just updated the "graphql-upload" and other packages versions in my node project and now when I tried to run it it's giving this error

Screenshot 2023-05-26 at 10 54 27 PM

here is what my old package.json file was before this update

Screenshot 2023-05-26 at 10 55 13 PM

and here is what it looks like after update

Screenshot 2023-05-26 at 10 55 37 PM

the one thing which I wanted to do (and did) was to remove this ""preinstall": "npx npm-force-resolutions","

please let me know how I can resolve this error

jaydenseric commented 1 year ago

Hi @aoneahsan , the error is because you can no longer import from a main module at "graphql-upload"; you need to specify exactly the module you want to import. E.g:

import graphqlUploadExpress from "grpahql-upload/graphqlUploadExpress.mjs";

You can see all the modules you can import here:

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

This is for optimal JavaScript module design.

These breaking changes about how modules can be imported have been documented in the changelog and GitHub releases for each of the major version you are upgrading past, including migration examples for each of the imports: