TypeError: Observable.of is not a function error typically occurs when you’re trying to “use the of() method from the Observable class in the RxJS library, but the method is not identified.”
The main reason for the error is “changes in the latest RxJS library versions.” Starting with RxJS version 6, the way you create and use observables, as well as the way you import operators, has changed.
In versions prior to RxJS 6, you can use:
import { Observable } from 'rxjs/Observable';
Observable.of(1, 2, 3);
But in RxJS version 6 and later, you must use:
import { of } from 'rxjs';
of(1, 2, 3);
If you are using RxJS 6 or later, you should update your imports and usage patterns accordingly. If you have a lot of existing code and don’t want to refactor everything immediately, you can also use rxjs-compat, a compatibility layer that allows older RxJS code to work with RxJS 6.
Conclusion
To fix the error:
- Ensure you have the correct version of RxJS installed.
- Update your code to use the new import and usage patterns.
- If needed, consider using
rxjs-compat
as a temporary solution.
That’s it!
Related posts
Cannot find module ‘rxjs-compat/Observable’

Krunal Lathiya is a seasoned Computer Science expert with over eight years in the tech industry. He boasts deep knowledge in Data Science and Machine Learning. Versed in Python, JavaScript, PHP, R, and Golang. Skilled in frameworks like Angular and React and platforms such as Node.js. His expertise spans both front-end and back-end development. His proficiency in the Python language stands as a testament to his versatility and commitment to the craft.