Module not found: Can't resolve 'apollo-upload-client'

2.1k views Asked by At

I'm on Next.js and can't resolve this issue.

I don't find any opened issue in their GitHub.

{
  "dependencies": {
    "@apollo/client": "^3.7.1",
    "@types/apollo-upload-client": "^17.0.2",
    "@types/node": "18.11.9",
    "@types/react": "18.0.25",
    "@types/react-dom": "18.0.9",
    "axios": "^1.1.3",
    "eslint": "8.27.0",
    "eslint-config-next": "13.0.4",
    "form-data": "^4.0.0",
    "graphql": "^16.6.0",
    "next": "13.0.4",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "styled-components": "^5.3.6",
    "typescript": "4.9.3"
  }
}
3

There are 3 answers

0
kareem kamal On

I had the same problem, I made sure I installed both

"apollo-upload-client": "^18.0.1",

"@types/apollo-upload-client": "^17.0.5",

also make sure you follow the Requirements in npm

But what really worked for me is replacing the adding createUploadLink.mjs to the import, like so

import createUploadLink from "apollo-upload-client/createUploadLink.mjs";

then create the client

const httpLink = createUploadLink({
  uri: "http://localhost:4000/graphql", // Replace with your GraphQL endpoint
});
0
Rashad Muntar On

I think this error is more of a version thing. I face the same issue with apollo-upload-client version 18.x.x. I needed to revert back to version 17.0.5 and everything worked. I hope apollo provides a more detailed documentation as to how to handle this in version 18.x.x

0
Maftunbek On
The engine "node" is incompatible with this module. Expected version "^18.15.0 || >=20.4.0". Got "16.20.2"

I upgrade the node version and this error went away