How to import `lodash` in RC.0

It used to work with just import * as _ from "lodash"; but I think something funny is happening with the new es2015 modules - it’s in the wrong place, i.e. _.default

see: http://stackoverflow.com/questions/39763944/typescript-do-you-import-lodash-with-es2015-modules

3 Likes

Hi,

Did you managed to make it works ? I have the same problem and can’t figure out what the problem is :s

Same issue for me .Anybody know how to fix this ?

Ok i managed to fix this you just need to do : npm install @types/lodash --save-dev --save-exact

It is written in the Changelog here.

I didn’t saw it.

@Siltor
I run your command but It didn’t work for me
when I try to use a function in lodash it say

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import * as _ from 'lodash'
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController) {
  }
  ionViewDidEnter(){
    console.log(_.isBoolean(true))
  }
}

I got this error

[20:52:39] bundle dev update started …
[20:52:39] RangeError: Maximum call stack size exceeded
at isArray (native)
at deepClone (\myApp\node_modules\rollup\dist\rollup.js:157:7)

[20:52:39] sass started …
[20:52:39] sass finished in 13 ms
[20:52:39] typescript compilation finished in 3.09 s
[20:52:39] rollup: Export ‘isBoolean’ is not defined by ‘\myApp.tmp\pages\home\home.js’

I do that:
import {differenceBy, orderBy, filter} from 'lodash';

but when I run Ionic serve, i have following error:
lodash.js does not export filter

ps: lodash installed with npm install @types/lodash --save-dev --save-exact

What works for me is
import _ from ‘lodash’

import _ from 'lodash' works.

But source maps are not working correctly and it Is transpiled and tree-shaken to lodash in main.js And this is how it appears in the Chrome debugger.

I think we need to wait for a few updates to ionic-app-scripts.

1 Like

Hello,
I have same issue with Microsoft azure

 Cannot find namespace 'Microsoft'

I have installed a @type with

npm install @types/cordova-plugin-ms-adal --save-dev --save-exact

Can you help me how to fix it?