简体   繁体   English

Angular2:Lodash工作但触发Typescript错误

[英]Angular2 : Lodash working but triggers a Typescript error

I did try to import lodash in my angular2 project. 我确实尝试在我的angular2项目中导入lodash。 It's working fine, but I keep having in my log the following error : 它工作正常,但我的日志中始终出现以下错误:

TS2307 Cannot find module 'lodash'.
[error] import * as _ from "lodash"

However, I don't have any issue using it. 但是,使用它没有任何问题。 Is there any tsconfig I have to change to prevent that from happening ? 我必须更改任何tsconfig来防止这种情况发生吗?

You need to declare external modules to TypeScript can type check them for you. 您需要向TypeScript声明外部模块才能为您键入检查它们。

Quick fix 快速解决

typings install lodash --global --save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM