Adding lodash to Ionic2 (via the blog Ionic and Typings)

Hi All,

I’m following this great blog post on Ionic and Typings (http://blog.ionic.io/ionic-and-typings/). I’ve done all the steps mentioned in the blog post .

I’ve installed the typings and used typings to install lodash (lodash@4.0.0). Strange thing is I’m not getting any errors in the compile time. (type script is not showing any errors). But in the runtime, when I access the lodash variable, it says

ionic $ Error: Cannot find module 'lodash' from <path/to/component> 

Following is my ts file

import * as lodash from 'lodash';

and Im accessing lodash inside one of my methods (`updateOptions`)

updateOptions(nodeName){
  let a = lodash.find(HashArray, function(e: any){
    return e.Name == nodeName;
  })
}

Any help would be much appreciated, Thanks in advance

cheers

Sam

This is probably a stupid question, but did you actually install loadash itself with npm?

hey @rapropos, thanks for the reply and its not a stupid question :). in fact it could be the problem :scream:

So after you mention about installing logdash itself, I tried

npm install lodash --save (with and without sudo)

but I’m getting this errors now

npm WARN package.json mobile-app@ No repository field.
npm WARN package.json mobile-app@ No README data
npm WARN package.json mobile-app@ No license field.
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "lodash" "--save"
npm ERR! node v4.1.1
npm ERR! npm  v2.14.4
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package @angular/common@2.0.0-rc.3 does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/platform-browser@2.0.0-rc.3 wants @angular/common@2.0.0-rc.3
npm ERR! peerinvalid Peer @angular/platform-browser-dynamic@2.0.0-rc.3 wants @angular/common@2.0.0-rc.3
npm ERR! peerinvalid Peer ionic-angular@2.0.0-beta.10 wants @angular/common@^2.0.0-rc.3
npm ERR! peerinvalid Peer angularfire2@2.0.0-beta.2 wants @angular/common@2.0.0-rc.2 

any idea what I’m doing wrong here, thanks again

cheers
Sam

I don’t know what you’re doing wrong, but I just followed the SAME steps with a fresh project (ionic start ... --v2) and it seemed to work fine. Version problem?

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.37
Ionic App Lib Version: 2.0.0-beta.20
ios-deploy version: 1.8.6 
ios-sim version: 5.0.8 
OS: Mac OS X El Capitan
Node Version: v5.12.0
Xcode version: Xcode 7.3 Build version 7D175