3

In my angular project, I recently upgraded rxjs to version 6. Now, a module from npm (inside the node_modules folder) is failing because of some breaking changes (old imports don't work anymore). I adapted the imports for my code, but how can I fix them for the dependency (angular2-markdown) I'm using?

I would like to use the old rxjs dependency for the angular2-markdown module and the new one for my code. Is this possible? I thought package-lock.json would make sure that this still works, but I don't find an entry that sets the dependency for angular2-markdown.

codepleb
  • 10,086
  • 14
  • 69
  • 111

2 Answers2

1

You can also check rxjs-compat library which will add support for older Rxjs Version code. https://www.npmjs.com/package/rxjs-compat

You can install using npm i rxjs-compat.

For safer, please remove node_modules, package-lock.json file and do fresh npm install.

Suresh Kumar Ariya
  • 9,516
  • 1
  • 18
  • 27
  • Thanks you, I ended up doing that after messing with the package-lock.json. It should be possible to add the old rxjs depencency there afaik. It worked correctly (it found the version and added it with it's hash and everything in the lockfile), but it is somehow not used by that specific module. I end up getting the same error. – codepleb Aug 05 '18 at 19:17
1

Not sure what your issue is. Most people are terrible at maintaining their deps. Suffice to say, have you tried switching to ngx-md which is the advice given on the deprecated angular2-markdown npm page - https://www.npmjs.com/package/angular2-markdown

I had a similar problem when upgrading to ng6 with a diff package. I aborted the ng6 upgrade. Switched to the new package. Then did the ng6 upgrade and it worked. Not sure the best approach for you but when you do the ng6 upgrade there is a lot of moving parts so best to reduce the amount of changes being made by doing as little at a time as possible and then testing it and saving to git before moving to the next part.

Also, I hope you did the ng6 upgrade using ng update as described on the ng6 page here - https://blog.angular.io/version-6-of-angular-now-available-cc56b0efa7a4

PS You don't mention an ng6 upgrade but the rxJS 6 upgrade comes for free with the ng6 upgrade hence the assumption sorry if it is wrong

PPS Are you using rxjs-compat which will allow you to upgrade to rxJS 6 whilst still allowing some parts of your code to use the old approach thus preventing breakages. Again this comes for free when you do the ng6 update - the link above talks about rxjs-compat BTW

danday74
  • 52,471
  • 49
  • 232
  • 283
  • I upgraded to ng6, yeah. I noticed the rxjs upgrade that is causing the issues. After a lot of tryouts with the package-lock.json file, I ended up just adding rxjs-compat. Thanks. This problem though should be resolveable by adding the older dependency of rxjs to the angular2-markdown module section in the package-lock.json. If anyone comes up with a solution for that, I guess I would accept that, because that's what this question basically is about. +1 and thank you very much for your help! :) – codepleb Aug 05 '18 at 19:15
  • package-lock.json is influenced by 3 things (1) package.json (2) the previous package-lock.json (3) node_modules folder - so it can get messy - try deleting node_modules and your previous lock file and then run npm install - it has sometimes produced for me a much cleaner lock file (if package.json is maintained properly), other times it can totally break the app lol - worth a shot tho - just make sure you can revert to the previous lock file if need be – danday74 Aug 05 '18 at 19:19