‘Observable’ is not a class derived from ‘Observable’

I just came across a very similar issue while developing a custom module for a project. I’m not 100% sure we were having the same problem, but it looks pretty close.

How I resolved my problem

I would suggest deleting your node_modules folder and reinstalling all your dependencies.

rm -rf node_modules/
npm cache clean
npm install

That solved it for me.

What the problem was (I think)

The module I was developing had an abstract class that the main project was trying to extend. However when trying to compile the main project, the compiler would throw the same error you are getting.

After a bit of digging around, I noticed NPM would complain about an UNMET PEER DEPENDENCY when installing my module into my project. When looking inside the node_modules of the project, I noticed that my module had another node_modules folder nested inside of it with some dependencies that it shared with the main project.

I’m not certain about this, but I think NPM thought the module was expecting different version of dependencies it shared with the main project.

So the abstract class inside the module was referencing Observable from its own nested node_modules folder while the main project was referencing Observable from the top level node_modules folder.

More information

This other questions provided some insight for me when trying solve my problem:

Why does npm install say I have unmet dependencies?

Leave a Comment