如何在 Typescript 项目中使用 "localForage"?
How to use "localForage" in Typescript project?
我在 Typescript 中有一个项目,我想使用依赖项“localForage”:https://github.com/localForage/localForage。
我通过以下 npm 命令安装了它:
npm install @types/localforage --save
我用过:
import * as localForage from "localforage";
我收到错误:
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.
它与我无关,因为我使用 Webstorm 10.0.5
在 Settings | Languages & Frameworks | TypeScript
- Set options manually
或 Use tsconfig.json
中选择了什么选项?在前一种情况下,请确保将 --module commonjs
指定为 命令行选项 值。否则,将 "module": "commonjs"
添加到您的 tsconfig.json
.
请注意,您使用的是非常旧的 webStorm 版本,其 Typescript 集成不是最新的,使用最新的 typescript 版本可能会遇到问题
我在 Typescript 中有一个项目,我想使用依赖项“localForage”:https://github.com/localForage/localForage。
我通过以下 npm 命令安装了它:
npm install @types/localforage --save
我用过:
import * as localForage from "localforage";
我收到错误:
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.
它与我无关,因为我使用 Webstorm 10.0.5
在 Settings | Languages & Frameworks | TypeScript
- Set options manually
或 Use tsconfig.json
中选择了什么选项?在前一种情况下,请确保将 --module commonjs
指定为 命令行选项 值。否则,将 "module": "commonjs"
添加到您的 tsconfig.json
.
请注意,您使用的是非常旧的 webStorm 版本,其 Typescript 集成不是最新的,使用最新的 typescript 版本可能会遇到问题