title: Ionic2 Import external Js File
body: <p>I'm trying to import an external js library, moment into Ionic 2.
  I have the moment modules stored in node modules however it seems web pack is not including it in my project directory.</p>
  
  <pre><code>&lt;body&gt;
  
    &lt;!-- Ionic's root component and where the app will load --&gt;
    &lt;ion-app&gt;&lt;/ion-app&gt;
  
    &lt;!-- The polyfills js is generated during the build process --&gt;
    &lt;script src="build/polyfills.js"&gt;&lt;/script&gt;
  
    &lt;!-- The bundle js is generated during the build process --&gt;
    &lt;script src="build/main.js"&gt;&lt;/script&gt;
  
    &lt;script src="node_modules/moment/moment.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>However when I look in my browser it is not included in the node modules</p>
  
  <p><a href="https://i.stack.imgur.com/LxmzX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LxmzX.png" alt="enter image description here"></a></p>
  
  <p>I have moment installed in my nose_modules however when ionic builds it does not appear in my browser as a file</p>
  
  <p>I'm using Ionic 2 and Angular 2.  My guess is that I need to specify to include it some how through the modules or web pack does anyone know how to do this?</p>
  
  <p>** Edit **
  Here is the ts page class</p>
  
  <pre><code>import { Component } from '@angular/core';
  import { NavController, NavParams } from 'ionic-angular';
  import { User } from '../../models/user';
  import { Users } from '../../providers/users';
  import moment from 'moment';
  
  
  @Component({
    selector: 'page-profile',
    templateUrl: 'profile.html'
  })
  export class ProfilePage {
  
      userId: number;
      user: User;
  
      getAge = () =&gt; {
          if (this.user) {
              return moment().diff(this.user.birthday, 'years');
          }
      }
  
      constructor(public navCtrl: NavController, public navParams: NavParams, private usersProvider: Users) {
  
          this.userId = navParams.get('userId');
  
          usersProvider.get(this.userId).subscribe(user =&gt; {
              this.user = user;
              console.log(user)
          });
      }
  
    ionViewDidLoad() {
      console.log('ionViewDidLoad ProfilePage');
    }
  }
  </code></pre>