# Lodash export errors in Ionic2 RC0

**URL:** <https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166>\
**Category:** ionic-v3\
**Created:** [September 30, 2016, 10:39am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166 "2016-09-30T10:39:12Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![julianmountford](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@julianmountford](https://forum.ionicframework.com/u/julianmountford)\
**Post date:** [September 30, 2016, 10:39am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/1 "2016-09-30T10:39:13Z")

</div>

I previously had my project building and running fine at Ionic2 beta 11. After following the instructions to update to rc0 (I used the “Copying your Project to a New Project method”) I have the following error when running ionic serve:  
lodash.js does not export find

The import line I’m using in the offending file is:  
import { find } from ‘lodash’;

As described in the instructions I installed the lodash types using this command:  
npm install @types/lodash --save-dev --save-exact

Also as described in the instructions I ensured there is no typings.json file or typings directory.

It doesn’t matter which lodash method I try to use, I always get the same problem. Does anyone know what I’m doing wrong here?

Here’s my Ionic info  
Cordova CLI: 6.3.1  
Gulp version: CLI version 3.9.1  
Gulp local: Local version 3.9.1  
Ionic Framework Version: 2.0.0-rc.0  
Ionic CLI Version: 2.1.0  
Ionic App Lib Version: 2.1.0-beta.1  
ios-deploy version: 1.8.5  
ios-sim version: 5.0.6  
OS: Mac OS X El Capitan  
Node Version: v4.6.0  
Xcode version: Xcode 8.0 Build version 8A218a

---

<div class="post-metadata">

**Author:** ![Siltor](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/siltor/32/103253_2.png) [@Siltor](https://forum.ionicframework.com/u/Siltor)\
**Post date:** [September 30, 2016, 10:43am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/2 "2016-09-30T10:43:46Z")

</div>

Hi, with the new RC you have to import lodash like this : `import _ from "lodash"`

There has been another topic for this problem 🙂

> [@How to import \`lodash\` in RC.0](https://forum.ionicframework.com/t/how-to-import-lodash-in-rc-0/64943/7):
>
> What works for me is import \_ from ‘lodash’

---

<div class="post-metadata">

**Author:** ![julianmountford](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@julianmountford](https://forum.ionicframework.com/u/julianmountford)\
**Post date:** [September 30, 2016, 10:57am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/3 "2016-09-30T10:57:21Z")

</div>

Doh, I did search the forum for @types but found nothing.  
Many thanks, it works fine now.

---

<div class="post-metadata">

**Author:** ![rajp](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rajp](https://forum.ionicframework.com/u/rajp)\
**Post date:** [October 4, 2016, 2:48am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/4 "2016-10-04T02:48:19Z")

</div>

I can’t get Lodash to work at all.

I tried the following:

1. import \* as \_ from “lodash”
2. import \_ from “lodash”

I’m getting errors like below during bundling:  
[19:25:05] rollup: Export ‘get’ is not defined by ‘…/services/auth-service.js’  
[19:25:05] rollup: Export ‘reverse’ is not defined by ‘…/products/products.js’  
[19:25:05] rollup: Export ‘values’ is not defined by ‘…/products/products.js’

This is driving me nuts. I have been trying for the past 3 days and I still couldn’t find a solution.

I ran this to install lodash:  
npm install @types/lodash --save --save-exact

---

<div class="post-metadata">

**Author:** ![symphony86](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@symphony86](https://forum.ionicframework.com/u/symphony86)\
**Post date:** [October 4, 2016, 2:50am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/5 "2016-10-04T02:50:58Z")

</div>

make sure to install npm @types/lodash

edit: sorry, you did have types… lemme check mine

---

<div class="post-metadata">

**Author:** ![rajp](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rajp](https://forum.ionicframework.com/u/rajp)\
**Post date:** [October 4, 2016, 3:03am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/6 "2016-10-04T03:03:23Z")

</div>

I don’t get any errors during compilation though.

Here are my dependencies

“dependencies”: {  
"@ionic/storage": “1.0.3”,  
"@types/crypto-js": “3.1.32”,  
"@types/lodash": “4.14.36”,  
“angularfire2”: “2.0.0-beta.5”,  
“firebase”: “3.4.1”,  
“ionic-angular”: “2.0.0-rc.0”,  
“ionic-native”: “2.0.3”,  
“ionicons”: “3.0.0”,  
“ng2-translate”: “3.0.0”,  
“swiper”: “3.3.1”  
},  
“devDependencies”: {  
"@ionic/app-scripts": “0.0.23”,  
"@types/request": “0.0.30”,  
“typescript”: “2.0.3”  
}

---

<div class="post-metadata">

**Author:** ![symphony86](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@symphony86](https://forum.ionicframework.com/u/symphony86)\
**Post date:** [October 4, 2016, 3:53am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/7 "2016-10-04T03:53:39Z")

</div>

do you actually install the lodash library itself? you need both lodash and @types/lodash

---

<div class="post-metadata">

**Author:** ![rajp](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rajp](https://forum.ionicframework.com/u/rajp)\
**Post date:** [October 4, 2016, 6:23am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/8 "2016-10-04T06:23:43Z")

</div>

I thought @types/lodash also pulls lodash. Here is my updated dependencies.

“dependencies”: {  
"@ionic/storage": “1.0.3”,  
“angularfire2”: “2.0.0-beta.5”,  
“crypto-js”: “3.1.6”,  
“firebase”: “3.4.1”,  
“ionic-angular”: “2.0.0-rc.0”,  
“ionic-native”: “2.0.3”,  
“ionicons”: “3.0.0”,  
“lodash”: “^4.16.3”,  
“ng2-translate”: “3.0.0”,  
“swiper”: “3.3.1”  
},  
“devDependencies”: {  
"@ionic/app-scripts": “0.0.23”,  
"@types/crypto-js": “3.1.32”,  
"@types/lodash": “4.14.36”,  
"@types/request": “0.0.30”,  
“typescript”: “2.0.3”  
}

But I still have the same problem. I looked at node\_modules directory and I see all the packages are there.

---

<div class="post-metadata">

**Author:** ![julianmountford](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@julianmountford](https://forum.ionicframework.com/u/julianmountford)\
**Post date:** [October 4, 2016, 7:26am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/9 "2016-10-04T07:26:52Z")

</div>

I don’t have lodash in my dependencies but I do have @types/lodash in my devDependencies:  
“dependencies”: {  
“ionic-angular”: “^2.0.0-rc.0”,  
“ionicons”: “^3.0.0”,  
"@ionic/storage": “^1.0.3”,  
“ionic-native”: “^2.0.3”  
},  
“devDependencies”: {  
"@ionic/app-scripts": “^0.0.23”,  
"@types/lodash": “4.14.36”,  
"@types/moment": “2.13.0”,  
“typescript”: “^2.0.3”  
},

To import lodash in a ts file:  
import \_ from ‘lodash’;

To use lodash in a method  
\_.get( … );  
\_.reverse( … );  
\_.values( … )

---

<div class="post-metadata">

**Author:** ![rajp](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rajp](https://forum.ionicframework.com/u/rajp)\
**Post date:** [October 5, 2016, 3:06am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/10 "2016-10-05T03:06:26Z")

</div>

@symphony86 and @julianmountford

I did everything mentioned in this thread but nothing worked for me.

Since I also need to get firebase to work I updated node\_modules/@ionic/app-script/config/rollup.config.js as per the instructions here: [https://playcode.org/getting-started-with-ionic-2-rc0-firebase-3-angularfire-2/](https://playcode.org/getting-started-with-ionic-2-rc0-firebase-3-angularfire-2/)

plugins: [  
ngTemplate(),  
// – CHANGES BELOW –  
commonjs({  
include: [  
‘node\_modules/rxjs/**’,  
'node\_modules/angularfire2/**’,  
‘node\_modules/firebase/**’,  
'node\_modules/@ionic/storage/**’,  
‘node\_modules/localforage/**’,  
'node\_modules/lodash/**’  
],  
namedExports: {  
‘node\_modules/firebase/firebase.js’: [‘initializeApp’, ‘auth’, ‘database’],  
‘node\_modules/angularfire2/node\_modules/firebase/firebase-browser.js’: [‘initializeApp’, ‘auth’, ‘database’]  
}  
}),  
// – CHANGES END –  
nodeResolve({  
module: true,  
jsnext: true,  
main: true,  
browser: true,  
extensions: [’.js’]  
})  
]

Do you think this is causing trouble with lodash?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [October 5, 2016, 5:23am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/11 "2016-10-05T05:23:33Z")

</div>

> [@rajp](#):
>
> I updated node\_modules/@ionic/app-script/config/rollup.config.js

Don’t do this. Never touch anything under `node_modules` manually. npm will cause you pain over and over again. Read [this](https://github.com/driftyco/ionic-app-scripts/) for how to properly override config files.

---

<div class="post-metadata">

**Author:** ![thomastthai](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@thomastthai](https://forum.ionicframework.com/u/thomastthai)\
**Post date:** [November 6, 2016, 6:18pm UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/12 "2016-11-06T18:18:09Z")

</div>

Did you ever get this to work? I am seeing the same issue.

Cordova CLI: 6.3.1  
Ionic Framework Version: 2.0.0-rc.2  
Ionic CLI Version: 2.1.4  
Ionic App Lib Version: 2.1.2  
Ionic App Scripts Version: 0.0.39  
OS:  
Node Version: v6.9.1

npm install @types/lodash --save-dev --save-exact  
npm install typings --global  
npm install lodash --save --global  
typings install lodash --save

“dependencies”: {  
"@angular/common": “2.1.1”,  
"@angular/compiler": “2.1.1”,  
"@angular/compiler-cli": “2.1.1”,  
"@angular/core": “2.1.1”,  
"@angular/forms": “2.1.1”,  
"@angular/http": “2.1.1”,  
"@angular/platform-browser": “2.1.1”,  
"@angular/platform-browser-dynamic": “2.1.1”,  
"@angular/platform-server": “2.1.1”,  
"@ionic/storage": “1.1.6”,  
"@types/lodash": “^4.14.38”,  
“ionic-angular”: “2.0.0-rc.2”,  
“ionic-native”: “2.2.3”,  
“ionicons”: “3.0.0”,  
“lodash”: “^4.16.6”,  
“rxjs”: “5.0.0-beta.12”,  
“zone.js”: “0.6.21”  
},  
“devDependencies”: {  
"@ionic/app-scripts": “0.0.39”,  
"@types/lodash": “4.14.38”,  
“typescript”: “2.0.6”  
},

Then I tried both of the following formats in my typescript file:

import \* as \_ from ‘lodash’;  
import \_ from ‘lodash’;

Both said: Cannot find module ‘lodash’

---

<div class="post-metadata">

**Author:** ![julianmountford](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@julianmountford](https://forum.ionicframework.com/u/julianmountford)\
**Post date:** [November 7, 2016, 8:56am UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/13 "2016-11-07T08:56:14Z")

</div>

Try removing @types/lodash from your dependencies but keep it in your devDependencies like this:

```
  "dependencies": {
    "@angular/common": "2.1.1",
    "@angular/compiler": "2.1.1",
    "@angular/compiler-cli": "2.1.1",
    "@angular/core": "2.1.1",
    "@angular/forms": "2.1.1",
    "@angular/http": "2.1.1",
    "@angular/platform-browser": "2.1.1",
    "@angular/platform-browser-dynamic": "2.1.1",
    "@angular/platform-server": "2.1.1",
    "@ionic/storage": "1.1.6",
    "ionic-angular": "2.0.0-rc.2",
    "ionic-native": "^2.2.3",
    "ionicons": "^3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "^0.6.21"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^0.0.39",
    "@types/lodash": "4.14.36",
    "@types/moment": "2.13.0",
    "typescript": "^2.0.6"
  },

```

To import lodash into a ts file:

```
import _ from 'lodash';

```

To use lodash in a method

```
_.get( ... );
_.reverse( ... );
_.values( ... );
```

---

<div class="post-metadata">

**Author:** ![zombiitv](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zombiitv/32/106449_2.png) [@zombiitv](https://forum.ionicframework.com/u/zombiitv)\
**Post date:** [March 3, 2017, 5:40pm UTC](https://forum.ionicframework.com/t/lodash-export-errors-in-ionic2-rc0/65166/14 "2017-03-03T17:40:59Z")

</div>

For those who find this thread and are using Ionic 2.1.0 - you need to use this for lodash to work

npm install @types/lodash@ts2.0 --save-dev --save-exact

note the @ts2.0 - if you leave that off it installs ts2.1 which is not compatible yet

then

import \* as \_ from “lodash”

should work
