The easiest way to get it done is usually to also import its type definition:
npm i --save-dev @types/lodash
(Or you could use const _ = require('lodash'); to avoid this install, but you'll loose all the types benefits.
Finally, if your project is a javascript one, but you'd like to get the types benefits, and if you're using VSCode, there's some settings in jsconfig.json to save the install step (I never used this personally, usually using either Typescript projects or typeless JS projects)
BTW, this is an Angular2 project
I can include my package.json file, if needed
Hmm, this is an Angular2 error then, not a Typescript one: the XHR/404 error implies the runtime (ie after typescript transpilation finished) tries to load lodash (the js file, not the type definition), and tried to load it from the root of your localhost.
I never used Angular2, so I don't know how it imports its dependencies, but this is definitely not related to types but rather looks ike a generic module-loading issue in Angular2 (which I don't know at all)
Sébastien Portebois
Software architect at Ubisoft
The easiest way to get it done is usually to also import its type definition:
npm i --save-dev @types/lodash(Or you could use
const _ = require('lodash');to avoid this install, but you'll loose all the types benefits.Finally, if your project is a javascript one, but you'd like to get the types benefits, and if you're using VSCode, there's some settings in
jsconfig.jsonto save the install step (I never used this personally, usually using either Typescript projects or typeless JS projects)"typeAcquisition": { "include": [ "lodash" ] }(src: JavaScript in VS Code documentation)
HTH