我在Typescript中有一个项目,我想使用依赖" localForage":https://github.com/localForage/localForage。
我通过以下npm命令安装它:
npm install @ types / localforage --save
我用过:
/// <reference path="typings/index.d.ts" />
///<reference path="node_modules/localforage/typings/localforage.d.ts"/>
import lf = require("./node_modules/localforage");
lf.setItem("blabla", "blabla");
lf.getItem("blabla", (err, data) => {
console.log(data);
})
当我在浏览器中运行它时,我收到错误:
未捕获错误:无法找到模块&#34; localforage&#34;来自&#34; undefined&#34;
我使用此链接来解决此问题:https://www.tomsdev.com/blog/2015/packaging-typescript-module-publish-npm-release/