I have a project where I'm creating an Angular Library, that is imported in another app as a UMD bundle.

I wanted to use Jsonpath library to parse json in one of the components in the library. When I try to use json path directly in the angular app, it works fine. But if I try to do the same thing in the library component, I get error saying

"ERROR TypeError: this.nodes is not a function"

Here's how I am trying to use it:

import { Component, OnInit } from '@angular/core';
import * as JP from 'jsonpath/jsonpath';

  selector: 'nom-test',
  templateUrl: './test.component.html',
  styleUrls: ['./test.component.css']
export class TestComponent implements OnInit {

  constructor() { }

  ngOnInit() {
    const t = {id:1};
    const r = JP.query(t, '$..*');


This works if the test-component is directly in the app, but doesn't if the component is in the library. I've tried using ng-packagr options "umdModuleId", externals but none of them seem to work.

If I try to add jsonpath to bundleDependencies in my library's package.json, I get the error

'query' is not exported by 'node_modules\jsonpath\jsonpath.js' Blockquote

I'm completely stumped on what could be causing this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.