I have a project in Typescript and I want to use the dependency "localForage": https://github.com/localForage/localForage.
I installed it by the following npm command:
npm install @types/localforage --save
I used:
import * as localForage from "localforage";
and I get the error:
error TS1148: Cannot compile modules unless the '--module' flag is provided I was looking for solutions and I found TypeScript 0.9.* VisualStudio TS5037: Cannot compile external modules unless the '--module' flag is provided.
It wasn't relevant for me because I use Webstorm 10.0.5
What option is chosen in Settings | Languages & Frameworks | TypeScript
- Set options manually
or Use tsconfig.json
? In the former case, make sure to specify --module commonjs
as Command line options value. Otherwise, add "module": "commonjs"
to your tsconfig.json
.
Note that you are using very old webStorm version, its TypeScript integration is not up-to-date, you might face issues using the recent TypeScript versions.