Update app.bundle.js file



I just added a moment.js library in my project by this command “npm install moment --save”, calling moment() displaying errors in console.

Do i have to update app.bandle.js file before calling it, if yes then how m i suppose to do that.



If you want to use moment.js in your app then it’s not npm that you must use, it’s bower.
npm is used to install tools.

bower install moment --save

Then depending on the gulp process you use, you may have to insert a script link to moment.js in your index.html


@gmarziou I believe your answer is targeted at Ionic 1 as Ionic 2 doesn’t use bower or gulp (it uses npm and webpack).

As for the OP – I haven’t tried momentjs yet but I was able to get lodash working for myself. I just npm i lodash --save, then inside my component I included import {zip} from 'lodash'; and I had access to lodash’s zip function inside my component’s class.


I was able to add momentjs to my component. After installing moment using npm (npm i moment --save) you need to go into your component and import it.


import {Page} from 'ionic/ionic';
import * as moment from 'moment';

  templateUrl: 'app/my-component/test-moment.html',
  directives: []
export class TestMoment {
  constructor() {


I’m using typescript, but I believe the ES6 import is the same format.

Note: I needed to also quit and restart ionic using ionic serve.


@BCKrueger thanks man i will give it a try and let you know.


Right, sorry I did not notice the tag.


This seems to have broken in ionic2 beta 3, any idea how I can add libraries now? Following the above I get

ERROR in [default] /......./app/app.ts:6:24 
Cannot find module 'moment'.


@ctcampbell with TypeScript you also have to install the type definitions (check out the linked post for details):