3

angular2 is returning lodash as an empty object.

npm install lodash --save
npm install @types/lodash --save

Imported as below :

import * as _ from "lodash";

_ is empty - what i'm doing wrong?

https://github.com/AngularClass/angular2-webpack-starter/issues/1302

Rohit
  • 2,987
  • 3
  • 25
  • 50
  • There's a similar question, did you tried? http://stackoverflow.com/questions/34660265/importing-lodash-into-angular2-typescript-application – Fals Dec 28 '16 at 13:13
  • yes i tried those solution. I am not getting any error, but lodash is empty. – Rohit Dec 28 '16 at 13:19
  • Should be the version, try a version below to see what happens! – Fals Dec 28 '16 at 13:24
  • "@types/lodash": "4.14.42", "lodash": "4.17.2" no luck – Rohit Dec 28 '16 at 13:32
  • But, the type version is different from the loadash version!!! makes no sense, there's something broken from the current version. – Fals Dec 28 '16 at 13:35
  • please let me know which version should i use, my friend is using the same process and everything is working fine on his system, even on his system angular-cli, node, typescript versions are same. – Rohit Dec 28 '16 at 13:39

1 Answers1

1

With "lodash": "^4.17.3" on dependencies and "@types/lodash": "^4.14.40" on devDependencies of the package.json file I was able to do

import * as lodash from 'lodash';

Wish that helps!

SeleM
  • 9,310
  • 5
  • 32
  • 51