【问题标题】:Cannot find type definition file for 'core-js'找不到“core-js”的类型定义文件
【发布时间】:2017-03-13 10:45:06
【问题描述】:

我正在使用angular-cli 构建一个angular2 应用程序。 angular-in-memory-web-api 默认没有安装。

所以我搜索并在我的package.json 文件中添加了这一行"angular-in-memory-web-api": "~0.1.5"。并做到了npm install

现在我遇到了这个问题。

ERROR in [default] /home/adil/Code/AngularJS.2/cli-based/mz-doc-app/node_modules/angular-in-memory-web-api/in-memory-backend.service.d.ts:1:0 
Cannot find type definition file for 'core-js'.

请提出一些解决方案?

package.json

{
  "name": "mz-doc-app",
  "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"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "~2.1.0",
    "@angular/compiler": "~2.1.0",
    "@angular/core": "~2.1.0",
    "@angular/forms": "~2.1.0",
    "@angular/http": "~2.1.0",
    "@angular/material": "^2.0.0-alpha.9-3",
    "@angular/platform-browser": "~2.1.0",
    "@angular/platform-browser-dynamic": "~2.1.0",
    "@angular/router": "~3.1.0",
    "@types/core-js": "^0.9.34",
    "angular-in-memory-web-api": "~0.1.5",
    "core-js": "^2.4.1",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.23"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.18",
    "codelyzer": "1.0.0-beta.1",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.9",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "~2.0.3"
  }
}

【问题讨论】:

    标签: javascript node.js angular typescript npm


    【解决方案1】:

    我通过删除node_modules/angular-in-memory-web-api/in-memory-backend.service.d.ts的第一行/// <reference types="core-js" />解决了这个问题

    这不是永久解决方案,但请等待修复 (https://github.com/angular/in-memory-web-api/issues/62)

    【讨论】:

      【解决方案2】:

      我在使用 webpack 时遇到了类似的问题。自 0.1.10 版以来,in-mem-web-api 发生了一些重大变化。

      https://github.com/angular/in-memory-web-api/blob/master/CHANGELOG.md#0113-2016-10-20

      将 web api 更改为 0.1.9 版可以为我清除症状。 (我是角菜鸟,所以很遗憾不知道永久解决方案)。

      【讨论】:

        猜你喜欢
        • 2018-07-20
        • 2021-08-15
        • 2017-06-18
        • 2018-07-31
        • 1970-01-01
        • 2022-11-03
        • 2019-05-15
        • 2017-06-09
        • 1970-01-01
        相关资源
        最近更新 更多