NPM-无法从lodash库中找到名称“很多",也无法找到名称空间"_" [英] NPM - Cannot find name 'Many' and Cannot find namespace '_' from lodash library

查看:74
本文介绍了NPM-无法从lodash库中找到名称“很多",也无法找到名称空间"_"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的angular2项目中使用lodash.

I'm trying to use lodash in my angular2 project.

$ npm install --save lodash

$ npm install --save @types/lodash

我从安装lodash时收到了此警告消息

I got this warning messages from installing lodash

这是一种类型

我忽略了这些警告消息,然后继续.现在,在我的组件中,添加了这一行.

I ignored those warning messages and continue. Now in my component, I added this line..

import * as _ from 'lodash';

当应用开始编译时,我在控制台中收到以下错误消息:

when the app starts to compile I get this errors in my console:

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

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"
  }
}

我在这里错过了什么吗?我需要见识同行吗?怎么样?

Am I missing something here? Do I need to meet the PEER DEPENDENCIES? How?

推荐答案

最新的lodash使用Typescript 2.1,它现在与尚不使用ts 2.0的ionic不兼容.您可以在我使用的 package.json 文件中看到

The latest lodash uses typescript 2.1 which is not compatible with ionic right now which uses ts 2.0 still. As you can see on my package.json file I used

"typescript": "2.0.10"

因此,如果您使用的版本与我的版本相同,并出现相同的错误,则只需安装

So, if you are using the same version as mine and ended up with the same error just install

$ npm install --save lodash

并将其添加到依赖项中的 package.json 文件中

and add this to your package.json file inside the dependencies

"dependencies": {
    ...
    "@types/lodash": "ts2.0"
}

$ npm install

您现在可以导入

import * as _ from "lodash";

这篇关于NPM-无法从lodash库中找到名称“很多",也无法找到名称空间"_"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆