I'm trying to import lodash in angular application level through main.ts like below.
//main.ts import * as lodash from 'lodash'; declare global { const _: typeof lodash; } After adding above code, I can able to reference to the lodash and compiled successfully but in run time I was facing issue like below.
ERROR ReferenceError: _ is not defined am I missing anything here? please help, thanks!

main.tsfile?@types/lodashso you have auto-completion, and then just import lodash in every file you need.(window as any)['_'] = lodashin youmain.ts. Withdeclareyou added type of global_everywhere, and with thatwindowproperty assignment you add actual value to be used in any context.(window as any)['_'] = lodashOr(globalThis as any)['_'] = lodash