angular2和compile问题找不到名字'Promise'

时间:2017-06-29 09:32:56

标签: angular typescript

我已经通过董事会并试图找到我的问题的解决方案。我的代码正在构建和运行,但在尝试包含一些国际化时,我会遇到打字稿错误。

运行此命令时

ng-xi18n --i18nFormat=xlf

我得到以下

Error: Error at ...node_modules/rxjs/Observable.d.ts:68:60: Cannot find name 'Promise'.
Error at ...node_modules/rxjs/Observable.d.ts:68:70: Cannot find name 'Promise'.
Error at ...node_modules/@angular/core/src/application_init.d.ts:21:27: Cannot find name 'Promise'.
Error at ...node_modules/@angular/core/src/change_detection/differs/iterable_differs.d.ts:15:48: Cannot find name 'Iterable'.
Error at ...node_modules/@angular/core/src/change_detection/differs/default_iterable_differ.d.ts:28:32: Cannot find name 'Iterable'.
Error at ...node_modules/@angular/core/src/linker/compiler.d.ts:43:49: Cannot find name 'Promise'.
Error at ...node_modules/@angular/core/src/linker/compiler.d.ts:51:65: Cannot find name 'Promise'.
Error at ...node_modules/@angular/core/src/application_ref.d.ts:116:76: Cannot find name 'Promise'.

我尝试了很多东西,但我的文件看起来像这样

tsconfig.json
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}

我运行的打字更新看起来很有希望,但看到了相同的结果。

npm install --save-dev typings -g

$(npm bin)/ typings install --global --save dt~core-js

tsc --rootDir src --outDir dist< - 这一行只显示了帮助

以下是package.json文件的一部分

"dependencies": {
    "@angular/common": "~4.2.4",
    "@angular/compiler": "~4.2.4",
    "@angular/core": "~4.2.4",
    "@angular/forms": "~4.2.4",
    "@angular/http": "~4.2.4",
    "@angular/platform-browser": "~4.2.4",
    "@angular/platform-browser-dynamic": "~4.2.4",
    "@angular/router": "~4.2.4",

    "angular-in-memory-web-api": "~0.3.0",
    "systemjs": "0.19.40",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "zone.js": "^0.8.4"
},

"devDependencies": {
    "@angular/compiler-cli": "~4.2.4",
    "@angular/platform-server": "~4.2.4",
    "@angular/animations": "~4.2.4",

    "concurrently": "^3.2.0",
    "lite-server": "^2.2.2",
    "typescript": "~2.1.0",

    "canonical-path": "0.0.2",
    "tslint": "^3.15.1",
    "lodash": "^4.16.4",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",

    "@types/core-js": "~0.9.42",
    "@types/node": "^6.0.46",
    "@types/jasmine": "2.5.36",

    "typings": "~2.1.1"
}

0 个答案:

没有答案