Skip to content
Advertisement

Unexpected token ‘export’ in lodash-es

I move from lodash to lodash-es in my typescript project .

I installed lodash-es and @types/lodash-es.

But when I compile using webpack my project it throw an error:

JavaScript

I’m not sure what the problem and how to solve this error?

Advertisement

Answer

From your error, looks like you are trying to load a esm module in node (v14+), by default only latest node version supports this kind of files.

There is no reason to use lodash-es in node enviroment.

The benefit of using lodash-es comes in browser related code, which will be bundled with one of the bundlers & enables a tree-shaking optimization.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement