1

^^^^^ No, it doesn't for two reasons. 1 - not using Angular2 (or I would have flagged it). 2 - the solution given in that "duplicate" clearly would never work - neither of the errors I'm getting appear in that question. So I've reposted with my own solution:

lodash-refers-to-a-umd-global

I am trying to use lodash in my application. I am using typescript, modularizing my code with export class MyClass and importing them using requirejs. jQuery seems to be unaffected, but lodash throws the following:

'_' referes to a UMD global, but the current file is a module. Consider adding an import instead.

So I do that: import * as _ from 'lodash' and I get

lodash.js is not a module

The first error is caused by the way in which the type definition file is structured. The second error is caused by requirejs not recognizing the umd format that lodash is wrapped in.

PS. I am using requirejs and MVC5. I realize this is not a common configuration in 2017 but I'm stuck with it.

AndrewBenjamin
  • 651
  • 1
  • 7
  • 16
  • Could you post your `tsconfig.json` contents, and the command that you execute for the process that triggers these errors? – JJWesterkamp Nov 27 '17 at 20:32
  • https://stackoverflow.com/a/39209948/1641941 first you could try `import _ from 'lodash'` if that doesn't work try to npm install the typings. – HMR Nov 28 '17 at 02:40

0 Answers0