apollo-link icon indicating copy to clipboard operation
apollo-link copied to clipboard

"Module not found: Can't resolve 'subscriptions-transport-ws" when using `apollo-link-ws`

Open nikolasburk opened this issue 7 years ago • 7 comments

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)

nikolasburk avatar Jan 22 '18 16:01 nikolasburk

Same issue

muhammad-abubakkar avatar Jan 29 '18 11:01 muhammad-abubakkar

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 avatar Jan 31 '18 12:01 anddoutoi

@anddoutoi Is this always going to be the case, or will this be fixed eventually?

supergoat avatar Feb 04 '18 00:02 supergoat

@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.

anddoutoi avatar Feb 05 '18 10:02 anddoutoi

I think you should close this as its done I guess

deadcoder0904 avatar Mar 09 '18 15:03 deadcoder0904

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.

bruno12mota avatar Dec 20 '18 16:12 bruno12mota

I get this error atm? Any ideas?

jamesmorgan avatar Apr 20 '20 19:04 jamesmorgan