javascriptgraphqlnestjsexpress-graphql

Error: No "exports" main defined in graphql-upload/package.json


Have installed graphql-upload, do

import { graphqlUploadExpress } from 'graphql-upload';

And getting this error: Error: No "exports" main defined in graphql-upload/package.json

Dependencies:

"graphql-upload": "^14.0.0",
"graphql": "15.8.0",
"graphql-request": "^4.2.0",
"graphql-tools": "^8.2.0",
"@nestjs/axios": "^0.0.7",
"@nestjs/common": "^8.4.1",
"@nestjs/config": "^1.1.5",
"@nestjs/core": "^8.4.1",
"@nestjs/graphql": "^9.1.2",
"@nestjs/platform-express": "^8.0.0",

The version of node: v16.10.0


Solution

  • So the problem was in the .default build settings. You can remove it, but when we removed it we saw the problem with other modules, so we resolved this issue via this:

    import Upload = require('graphql-upload/Upload.js');
    

    It looks very dirty, but it works.

    You can check conversation about this module in issues on GitHub: https://github.com/jaydenseric/graphql-upload/issues/305#issuecomment-1136574019