简体   繁体   English

找不到'core-js'的类型定义文件

[英]Cannot find type definition file for 'core-js'

I am building an angular2 application with angular-cli . 我正在构建一个angular-cliangular2应用程序。 angular-in-memory-web-api was not installed by default. 默认情况下未安装angular-in-memory-web-api

So I searched for it and added this line "angular-in-memory-web-api": "~0.1.5" in my package.json file. 所以我搜索了它并在我的package.json文件中添加了这行"angular-in-memory-web-api": "~0.1.5" And did npm install . npm installnpm install

Now I am having this issue. 现在我遇到了这个问题。

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'.

Please suggest some solution ? 请建议一些解决方案?

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

I solved the problem by deleting the first line /// <reference types="core-js" /> of node_modules/angular-in-memory-web-api/in-memory-backend.service.d.ts 我通过删除第一行/// <reference types="core-js" /> of node_modules/angular-in-memory-web-api/in-memory-backend.service.d.ts解决了这个问题。

It's not a permanent solution but wait for a fix ( https://github.com/angular/in-memory-web-api/issues/62 ) 它不是一个永久的解决方案,而是等待修复( https://github.com/angular/in-memory-web-api/issues/62

I had a similar issue using webpack. 我有一个类似的问题使用webpack。 There are some breaking changes to the in-mem-web-api since version 0.1.10. 自版本0.1.10以来,in-mem-web-api有一些重大变化。

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

Changing the web api to version 0.1.9 clears the symptom for me. 将web api更改为版本0.1.9可以清除我的症状。 (I'm an angular noob, so unfortunately don't know the permanent solution). (我是一个有角度的菜鸟,所以很遗憾不知道永久的解决方案)。

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

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