Typescript lodash no default export for one function Typescript lodash no default export for one function typescript typescript

Typescript lodash no default export for one function


You can import a single function from lodash using import isEqual from 'lodash/isEqual'; in typescript with the esModuleInterop flag in the compiler options (tsconfig.json)

example

{  "compilerOptions": {    "module": "commonjs",    "target": "es5",    "lib": ["es6", "dom"],    "moduleResolution": "node",    "esModuleInterop": true,    ...  }}


i had same problem, and i ended up here,

so here is the solution:

you need to install lodash-es

npm install --save lodash-es

instead of normal lodash

and read this link

https://medium.com/@armno/til-importing-lodash-into-angular-the-better-way-aacbeaa40473

update 1:it should really be easier, but anyway

point 1: install typings

 npm i -D @types/lodash-es

point 2: import from "lodash-es" not "lodash"

point 3: import like this, it's proper way (otherwise you will get a much larger bundle)

import  orderBy  from 'lodash-es/orderBy';


I managed to get this working for a similar error by using:

import * as get from 'lodash.get';