apollographql / apollo-link-state

✨ Manage your application's state with Apollo!
MIT License
1.4k stars 100 forks source link

Not compatible with graphql-anywhere@4.2.0: Cannot find module 'graphql-anywhere/lib/async' #346

Closed elliottsj closed 5 years ago

elliottsj commented 5 years ago

apollo-link-state imports the path 'graphql-anywhere/lib/async', but this does not work with graphql-anywhere@4.2.0 since it now publishes this file as lib/async.umd.js:

internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'graphql-anywhere/lib/async'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at connectionRemoveConfig.test (/Users/spencerelliott/path/to/node_modules/apollo-link-state/lib/bundle.umd.js:2:155)
    at Object.<anonymous> (/Users/spencerelliott/path/to/node_modules/apollo-link-state/lib/bundle.umd.js:5:2)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

Should this have been considered a breaking change by graphql-anywhere? Not sure if the lib/async module is considered part of its public API.

pehlse commented 5 years ago

I have same error in production

dustinbrink commented 5 years ago

Same

Module not found: Can't resolve 'graphql-anywhere/lib/async' in 'C:\git\vqadmin\node_modules\apollo-link-state\lib'
(node:16944) UnhandledPromiseRejectionWarning: Error: Cannot find module 'C:\git\vqadmin\.next\build-manifest.json'

I had to add a resolution to my package.json to work around it for now

"resolutions": {
    "graphql-anywhere": "4.1.0",
  }
lilactown commented 5 years ago

Same, this was a transitive dependency of apollo-boost 0.1.4.

koba1108 commented 5 years ago

The same error occurs even when using @nuxtjs/apollo. https://github.com/nuxt-community/apollo-module

whilelucky commented 5 years ago

I added this to my dependencies and it works for now

"dependencies": {
  ...
  "graphql-anywhere": "4.1.0",
  ...
}
andramalmen commented 5 years ago

I added this to my dependencies and it works for now

"dependencies": {
  ...
  "graphql-anywhere": "4.1.0",
  ...
}

I can confirm that fixed it for me too

njwest commented 5 years ago

+1 on this fix

"dependencies": {
  ...
  "graphql-anywhere": "4.1.0",
  ...
}

Thanks a ton for sharing this fix @lakshyaranganath, I ran into this error after doing a fresh npm install today an hour before a big UI prototype demo... almost didn't have a UI to demo!

That was a close one...

hwillson commented 5 years ago

Thanks for reporting this all - this was fixed in https://github.com/apollographql/apollo-client/pull/4503, and will de deployed shortly.

skatcat31 commented 5 years ago

We found a different way of solving this problem: https://www.apollographql.com/docs/react/essentials/local-state.html#migrating