I'm trying to import lodash into a file in Angular2 with TypeScript built with Webpack. I always get an error Cannot find module 'lodash'
or Cannot find module 'lodash/submodule'
. However, the code still works properly and in fact if I don't do the import
the code does not work properly.
import * as lodash from "lodash";
export class SomeService {
fn(): any {
return lodash.range(1, 2);
}
}
This works properly, but I still get the Cannot find module error
. I've also tried with import lodash from "lodash"
, import {range} from "lodash"
and import * as range from "lodash/range"
among a few other things, but no matter what, I always get this error.
I've done yarn add lodash
and typings install lodash
. node_modules/lodash
exists and has node_ modules/lodash/range.js
exist. In fact, import * as moment from "moment"
seems to be working fine.
Is there any way to get TypeScript to stop reporting this as an error?