Cordova 离子2构建抱怨无法使用模块lodash

Cordova 离子2构建抱怨无法使用模块lodash,cordova,angular,gulp,ionic2,typescript1.8,Cordova,Angular,Gulp,Ionic2,Typescript1.8,我在爱奥尼亚v2上,每次运行爱奥尼亚构建android时,我都会看到以下错误 TypeScript错误:/path/to/project/app/models/models.ts(1,20):错误TS2307:找不到模块“lodash” 看到这个错误,我真的看不出有什么副作用。例如,我的移动应用程序在浏览器、模拟器和设备中运行良好。然而,我想知道如何消除这个错误 当我添加lodash时,我必须输入以下命令 npm install lodash --save typings install lod

我在爱奥尼亚v2上,每次运行
爱奥尼亚构建android
时,我都会看到以下错误

TypeScript错误:/path/to/project/app/models/models.ts(1,20):错误TS2307:找不到模块“lodash”

看到这个错误,我真的看不出有什么副作用。例如,我的移动应用程序在浏览器、模拟器和设备中运行良好。然而,我想知道如何消除这个错误

当我添加
lodash
时,我必须输入以下命令

npm install lodash --save typings install lodash --save 有关我的开发工具版本的其他信息

  • 节点4.3.1
  • npm 3.8.6
  • gulp CLI 1.2.1,本地3.9.1
  • 科尔多瓦6.2.0
  • 鲍尔1.7.9
  • tsc 1.8.10
运行npm列表--depth=0以下是我的依赖项

├── @angular/common@2.0.0-rc.2 ├── @angular/compiler@2.0.0-rc.2 ├── @angular/core@2.0.0-rc.2 ├── @angular/http@2.0.0-rc.2 ├── @angular/platform-browser@2.0.0-rc.2 ├── @angular/platform-browser-dynamic@2.0.0-rc.2 ├── @angular/router@2.0.0-rc.2 ├── del@2.2.0 ├── es6-shim@0.35.1 ├── gulp@3.9.1 ├── gulp-watch@4.3.5 ├── ionic-angular@2.0.0-beta.8 ├── ionic-gulp-browserify-typescript@1.1.0 ├── ionic-gulp-fonts-copy@1.0.0 ├── ionic-gulp-html-copy@1.0.0 ├── ionic-gulp-sass-build@1.0.0 ├── ionic-gulp-scripts-copy@2.0.0 ├── ionic-native@1.2.4 ├── ionicons@3.0.0 ├── lodash@4.13.1 ├── reflect-metadata@0.1.3 ├── run-sequence@1.1.5 ├── rxjs@5.0.0-beta.6 └── zone.js@0.6.12 ├── @棱角的/common@2.0.0-rc.2 ├── @棱角的/compiler@2.0.0-rc.2 ├── @棱角的/core@2.0.0-rc.2 ├── @棱角的/http@2.0.0-rc.2 ├── @角度/平台-browser@2.0.0-rc.2 ├── @角度/平台浏览器-dynamic@2.0.0-rc.2 ├── @棱角的/router@2.0.0-rc.2 ├── del@2.2.0 ├── es6-shim@0.35.1 ├── gulp@3.9.1 ├── 吞咽-watch@4.3.5 ├── 离子的-angular@2.0.0-beta.8 ├── 离子型大口棕色化-typescript@1.1.0 ├── 爱奥尼亚吞咽字体-copy@1.0.0 ├── 爱奥尼亚吞咽html-copy@1.0.0 ├── 离子性吞咽-build@1.0.0 ├── 离子吞咽脚本-copy@2.0.0 ├── 离子的-native@1.2.4 ├── ionicons@3.0.0 ├── lodash@4.13.1 ├── 反映-metadata@0.1.3 ├── 跑-sequence@1.1.5 ├── rxjs@5.0.0-beta.6 └── 区js@0.6.12 我是根据我的想法想出来的。无论出于何种原因,编译器都会抱怨,因为它找不到
lodash
(在我的例子中是
jquery
)的类型定义

为了解决这个问题,我刚刚在我的
app.ts
文件的第一行中添加了一个三斜杠引用:

/// <reference path="../typings/index.d.ts" />
//

所有的错误都消失了。

+1我注意到了同样的问题。
jquery
也会发生:
TypeScript错误:错误TS2307:找不到模块“jquery”。
我不得不修改
typings/main.d.ts
来添加引用。部分问题是我使用的是
typings
的旧版本,它在
main.d.ts
中生成代码。然后我升级了我的
打字
,现在参考资料被放在
index.d.ts
中。
/// <reference path="../typings/index.d.ts" />