Problems using npm package


#1

I am trying to use the RRule package (just adding it to demo MyIonic2Project and trying to set up a page that creates a single RRule and lists out the instances) . Although I don’t use any nlp.js functionality when I do ionic serve it fails to load in the browser with nlp.js:28 Uncaught TypeError: Cannot read property ‘RRule’ of undefined. If I comment out the whole of nlp.js it works as expected.

Not sure if the fault is with the build process or the package - I do not have much of an understanding of modules etc. Can anybody point me in the right direction?

Thanks in advance.

Steps to reproduce:

ionic start wtf tutorial --v2
cd wtf
npm i rrule --save
typings install dt~rrule --global --save

Add files:
pages/rrule/rrule.ts

import { Component, OnInit } from '@angular/core';
import { RRule } from 'rrule';

@Component({
  templateUrl: 'rrule.html'
})
export class RRulePage implements OnInit{

    dates: string[];

  constructor() { }

  ngOnInit() {
    let rule = new RRule({
        freq: RRule.WEEKLY,
        interval: 5,
        byweekday: [RRule.MO, RRule.FR],
        dtstart: new Date(2012, 1, 1, 10, 30),
        until: new Date(2012, 12, 31)
        });
    this.dates = rule.all();
  }
}

pages/rrule/rrule.html

 <ion-header>
   <ion-navbar>
     <button ion-button menuToggle>
       <ion-icon name="menu"></ion-icon>
     </button>
     <ion-title>A Calendar Rule</ion-title>
   </ion-navbar>
 </ion-header>
 <ion-content>
   <ion-list>
     <button ion-item *ngFor="let date of dates">
       {{ date }}
     </button>
   </ion-list>
 </ion-content>

Modify app.module.ts and app.component.ts to add page and module

ionic serve


#2

It could be the typings. Recently Ionic 2 switched to @types instead of typings.


#3

Did you ever find an answer for this?