- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试在我的 angular2 项目中使用 lodash。
$ npm install --save lodash
$ npm install --save @types/lodash
我忽略了那些警告信息并继续。现在在我的组件中,我添加了这一行..
import * as _ from 'lodash';
当应用程序开始编译时,我在控制台中收到以下错误:
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:244:12
Duplicate identifier '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:244:15
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:246:24
Cannot find name 'Partial'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:248:18
Duplicate identifier '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:366:38
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:2083:23
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5585:43
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5592:43
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5599:43
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5606:43
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5639:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5648:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5655:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5662:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5671:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5678:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5685:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5694:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5701:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5708:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5717:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5724:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:5731:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:8
A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:9
Cannot find name 'P'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:14
Cannot find name 'keyof'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:20
']' expected.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:20
Cannot find name 'T'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:21
';' expected.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:22
Declaration or statement expected.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:25
A parameter initializer is only allowed in a function or constructor implementation.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:30
Cannot find name 'T'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:32
']' expected.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:33
')' expected.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:34
Declaration or statement expected.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:36
Declaration or statement expected.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11444:39
Cannot find name 'boolean'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11453:28
Cannot find name 'ConformsPredicateObject'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:11464:41
Cannot find name 'ConformsPredicateObject'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15394:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15403:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15436:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15445:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15480:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15489:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15522:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15531:11
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15564:21
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15571:21
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15604:23
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15611:23
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15627:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15636:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15646:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15656:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15666:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15676:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15686:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15696:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15731:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15739:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15746:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15778:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15786:20
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15793:20
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15856:20
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15856:36
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:15872:20
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16533:32
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16543:32
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16553:32
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16622:32
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16631:32
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16640:32
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16700:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16709:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16719:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16729:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16739:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16749:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16759:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16769:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16788:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16797:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16806:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16816:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16824:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16834:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16842:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16864:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16874:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16884:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16895:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16904:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16915:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:16924:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17081:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17089:20
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17096:20
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17112:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17121:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17130:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17139:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17149:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17157:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17167:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17175:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:17926:38
Cannot find name 'TemplateSettings'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18546:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18554:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18676:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18684:18
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18693:46
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18702:46
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18818:30
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18855:42
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18862:42
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18869:42
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18876:42
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18883:42
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18895:39
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18902:39
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18909:39
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18916:39
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18923:39
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18935:38
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18942:38
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18949:38
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18956:38
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18963:38
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:18974:38
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19014:52
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19021:57
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19028:57
Cannot find name 'Many'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19188:21
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19212:21
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19235:22
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19258:22
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19281:20
Cannot find namespace '_'.
ERROR in [default] /path/to/project/node_modules/@types/lodash/index.d.ts:19441:0
Declaration or statement expected.
package.json
{
"name": "final-project",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor",
"populate-db": "./node_modules/.bin/ts-node ./populate-db.ts",
"batch-server": "./node_modules/.bin/ts-node ./batch-server.ts"
},
"private": true,
"dependencies": {
"@angular/common": "2.0.1",
"@angular/compiler": "2.0.1",
"@angular/core": "2.0.1",
"@angular/forms": "2.0.1",
"@angular/http": "2.0.1",
"@angular/platform-browser": "2.0.1",
"@angular/platform-browser-dynamic": "2.0.1",
"@angular/router": "3.0.0",
"@types/lodash": "^4.14.52",
"@types/request": "0.0.30",
"angularfire2": "^2.0.0-beta.8",
"core-js": "^2.4.0",
"firebase": "^3.6.9",
"firebase-queue": "^1.5.0",
"lodash": "^4.17.4",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.21"
},
"devDependencies": {
"@types/jasmine": "^2.2.30",
"angular-cli": "1.0.0-beta.16",
"codelyzer": "~0.0.26",
"jasmine-core": "2.4.1",
"jasmine-spec-reporter": "2.5.0",
"karma": "0.13.22",
"karma-chrome-launcher": "0.2.3",
"karma-jasmine": "0.3.8",
"karma-remap-istanbul": "^0.2.1",
"protractor": "4.0.3",
"ts-node": "^1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.10"
}
}
我是不是漏掉了什么?我需要满足 PEER DEPENDENCIES 吗?怎么办?
最佳答案
最新的 lodash 使用 typescript 2.1,它现在与仍然使用 ts 2.0 的 ionic 不兼容。正如您在我使用的package.json 文件中看到的
"typescript": "2.0.10"
因此,如果您使用的版本与我的相同,但最终出现相同的错误,只需安装
$ npm install --save lodash
并将其添加到依赖项中的 package.json 文件
"dependencies": {
...
"@types/lodash": "ts2.0"
}
和
$ npm install
现在可以导入
import * as _ from "lodash";
关于angular - NPM - 无法从 lodash 库中找到名称 'Many' 和命名空间 '_',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42342978/
使用lodash,如何将生日相同的人的姓名归为一组,如下所示? 我使用嵌套的for循环写出了这个信息,但我想在lodash中会有一种更优雅的方法。我没有使用太多,并试图找出要使用的功能。 [
嘿,我想使用 lodash 计算对象数组中一个属性的总和 假设对象数组看起来像这样...... salary":[{ "bills":[{"electricity":300,"milk":500
我试图在调整窗口大小时触发一个事件,它似乎不起作用。 $(window).resize(function(){ _.debounce(function(){ console.log
我正在使用 StencilJS 编写一个网络组件。由我的组件导入的辅助类之一 (ArrayHelper.ts) 在顶部有这些导入: import transform from 'lodash/tran
我想用比较器对数组进行排序,例如: function myCustomComparator(a, b){...} 好像是 var sorted = myArray.sort(myCustomCompa
我试图弄清楚 Lodash iteratee 的工作原理以及我将在哪里使用它。 The documentation says: Creates a function that invokes func
我是 lodash (v3.10.1) 的新手,很难理解。希望有人能帮忙。 我有这样的输入: { {"id":1,"name":"Matthew","company":{"id":1,"na
我正在尝试添加到流类型的类型中。我从 lodash/fp 模块开始,因为它对我自己最有用。但是,我正在为如何正确输入它而苦苦挣扎。 如果 dropRightWhile 的一个简单示例: declare
有没有办法获取 lodash API 文档的 2.x 版本?上周末似乎主要链接已切换到 3.x,无法查看 2.x 文档。 https://lodash.com/docs 最佳答案 您可以在 Inter
为了减少 Angular 项目的包大小,我正在安装和导入单独的 lodash 库。 IE。 lodash.clonedeep 和其他 lodash.* 但会丢失这些的类型定义,因为它们不能与 @typ
像这样从 lodash 导入"template"有什么区别: import { template } from 'lodash'; 或者像这样: import template from 'lodas
我看到导入整个 lodash 库占用了相当多的磁盘空间: $ du . | grep lodash 1696 ./lodash/fp 5000 ./lodash 在我的代码中我只是在做 r
According to the lodash docs , _.extend(object, [sources]) 改变第一个参数。 var dest = { a: 1 }; _.extend(
我想创建值为“str”的键数组我有以下嵌套 json: [ { "Attr": [ { "power": { "p1": "str", "t3": "str"
lodash 提供了一个方法 _.uniq()从数组中查找唯一元素,但使用的比较函数是严格相等 === , 而我想使用 _.isEqual() ,满足: _.isEqual([1, 2], [1, 2
是escape和 unescape underscore 的功能和 lodash相同?我也可以吗escape与 lodash和 unescape与 underscore并且总是得到相同的字符串? 我可
我知道 rxjs 和 lodash 的定义和职责,但我想知道: 当我在我的项目中使用 rxjs 时,我可以扔掉 lodash 吗? 因为 rxjs 可以同步和异步工作(异步和同步数据)。我认为它可以作
使用 lodash 我想找到一个 id 为 3229 的团队。我尝试关注但它没有返回任何内容。 var team = _.chain(data.teams) .flatten(
我想知道 2 次导入在内存和性能方面是否有任何差异。 如果我的节点模块中有 lodash,无论导入如何,它都会编译所有文件吗? 最佳答案 理论上,based on the specification
基本上,我有一个对象数组,我只想更新数组中满足条件的对象。我想知道是否有解决该问题的有效方法。现在我正在使用 lodash。这是一个例子: var things = [ {id: 1, typ
我是一名优秀的程序员,十分优秀!