Search code examples
angularlodash

error TS1192: Module @types/lodash/index has no default export


I'm using Angular 6.x.x in my project with the following lodash dependency.

  "dependencies": {
    "@angular/common": "6.0.9",
    "@angular/core": "6.0.9",
    ...
    "@types/lodash": "^4.14.114",
    ...
  },

Both of the following import are not working for me.

import _ from 'lodash';  

import * as _ from 'lodash';

Solution

  • It seems like the following import was working perfectly fine. I had issues with my environment. After deleting the node_modules directory and installing it, it worked.

    import * as _ from 'lodash';