I am a bit confused about NPM package versions
I have ionic2 app and in my packages.json i have dependency to rxjs@5.1.1 also I have latest ionic-native which has dependency to rxjs@5.0.1.
Now the problem is that I wrote extension to Observable to add new method. It works as expected on my services. But it does not work when i am using services from ionic-native.
This method will work (Get commands simply return Observable)
updateService.getCommands().ExtensionHere();
This will not (onChange will return Observable)
BatteryStatus.onChange().ExtensionHere();
This is silly question but i am a bit in stuck since I thought that NPM will use latest version for all of them.
So my question is why it works in this way? And is this there any way to say well use same package version?
This is silly question but i am a bit in stuck since I thought that NPM will use latest version for all of them.
No. Each modules gets its own version if it requests it.
And is this there any way to say well use same package version?
It would only work that way if these library had rxjs
as a peerDependency. With peerDependencies
you get to decide the exact version. But that would require ionic-native
to change their code.
require both versions manually to add your extension i.e. require('../node_modules/your/node_modules/rxjs')
and same for theirs.