apollo-link
apollo-link copied to clipboard
"Module not found: Can't resolve 'subscriptions-transport-ws" when using `apollo-link-ws`
Intended outcome:
Using apollo-link-ws
should be possible without explicitly installing subscriptions-transport-ws
.
Actual outcome:
Right now, after installing and using apollo-link-ws
in my code, I'm getting the following error in my terminal:
./node_modules/apollo-link-ws/lib/webSocketLink.js
Module not found: Can't resolve 'subscriptions-transport-ws' in '/.../myapp/node_modules/apollo-link-ws/lib'
A workaround is to explicitly install subscriptions-transport-ws
(e.g. with yarn add subscriptions-transport-ws
)
Same issue
It's an inconvenience I know. But when you ran npm install apollo-link-ws
I'm pretty sure you got some output that resembled something like:
npm WARN [email protected] requires a peer of subscriptions-transport-ws@^0.9.0 but none is installed. You must install peer dependencies yourself.
+ [email protected]
added 1 package in 8.938s
The important part here is: You must install peer dependencies yourself.
The same issue was discussed here and it contains some explanation on why it's listed in peerDependencies
.
@anddoutoi Is this always going to be the case, or will this be fixed eventually?
@supergoat I don't know. I'm not a contributor or anything like that. I ended up here cause I had the same issue and accepted that it's a peer dependency and that I hadn't bothered reading what the CLI told me. It's the same with a lot of other stuff, eslint
is a peer dependency of all eslint plugins so you always have to install eslint
explicitly. I don't know if the question "will this be fixed" even make sense. This is how the eco system works.
I think you should close this as its done I guess
This makes sense if your server and client are on the same project. But if you have them separate this doesn't make sense and forces you to include node libraries polyfils to make it work which increases bundle size by a lot since subscriptions-transport-ws is meant to be run in node not on a browser environment. Best option would be to separate these concerns.
I get this error atm? Any ideas?