错误:Zone.js检测到ZoneAwarePromise`(window | global).Promise`已被覆盖

时间:2017-07-01 02:04:41

标签: angular eclipse-plugin

我的工作区由Eclipse Luna和TypeScript构建angular2项目。我一直有这个问题。

错误讯息:



Unhandled promise rejection ZoneAwareError {__zone_symbol__error: Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Mo……}message: (...)name: (...)originalStack: (...)stack: (...)toSource: function ()toString: function ()zoneAwareStack: (...)__zone_symbol__error: Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)
    at Function.Zone.assertZonePatched (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:40:23) [<root>]
    at new NgZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:3805:18) [<root>]
    at PlatformRef_._bootstrapModuleFactoryWithZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8030:26) [<root>]
    at eval (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8084:63) [<root>]
    at l (http://127.0.0.1:59058/codelive-assets/bundle.js:2:18437) [<root>]
    at http://127.0.0.1:59058/codelive-assets/bundle.js:2:18559 [<root>]
    at MutationObserver.a (http://127.0.0.1:59058/codelive-assets/bundle.js:2:22691) [<root>]
    at Zone.runGuarded (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:139:47) [<root> => <root>]
    at MutationObserver.<anonymous> (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:117:29) [<root>]originalStack: "Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.↵Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)↵    at ZoneAwareError (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:992:33)↵    at Function.Zone.assertZonePatched (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:40:23)↵    at new NgZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:3805:18)↵    at PlatformRef_._bootstrapModuleFactoryWithZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8030:26)↵    at eval (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8084:63)↵    at l (http://127.0.0.1:59058/codelive-assets/bundle.js:2:18437)↵    at http://127.0.0.1:59058/codelive-assets/bundle.js:2:18559↵    at MutationObserver.a (http://127.0.0.1:59058/codelive-assets/bundle.js:2:22691)↵    at ZoneDelegate.invoke (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:334:26)↵    at Zone.runGuarded (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:139:47)↵    at MutationObserver.<anonymous> (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:117:29)"zoneAwareStack: "Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.↵Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)↵    at Function.Zone.assertZonePatched (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:40:23) [<root>]↵    at new NgZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:3805:18) [<root>]↵    at PlatformRef_._bootstrapModuleFactoryWithZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8030:26) [<root>]↵    at eval (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8084:63) [<root>]↵    at l (http://127.0.0.1:59058/codelive-assets/bundle.js:2:18437) [<root>]↵    at http://127.0.0.1:59058/codelive-assets/bundle.js:2:18559 [<root>]↵    at MutationObserver.a (http://127.0.0.1:59058/codelive-assets/bundle.js:2:22691) [<root>]↵    at Zone.runGuarded (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:139:47) [<root> => <root>]↵    at MutationObserver.<anonymous> (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:117:29) [<root>]"message: "Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.↵Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)"stack: "Error: Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.↵Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)↵    at Function.Zone.assertZonePatched (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:40:23) [<root>]↵    at new NgZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:3805:18) [<root>]↵    at PlatformRef_._bootstrapModuleFactoryWithZone (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8030:26) [<root>]↵    at eval (http://localhost:8080/angularTest/node_modules/@angular/core/bundles/core.umd.js:8084:63) [<root>]↵    at l (http://127.0.0.1:59058/codelive-assets/bundle.js:2:18437) [<root>]↵    at http://127.0.0.1:59058/codelive-assets/bundle.js:2:18559 [<root>]↵    at MutationObserver.a (http://127.0.0.1:59058/codelive-assets/bundle.js:2:22691) [<root>]↵    at Zone.runGuarded (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:139:47) [<root> => <root>]↵    at MutationObserver.<anonymous> (http://localhost:8080/angularTest/node_modules/zone.js/dist/zone.js:117:29) [<root>]"__proto__: Objectget message: function ()set message: function (value)get name: function ()set name: function (value)get originalStack: function ()set originalStack: function (value)get stack: function ()set stack: function (value)get zoneAwareStack: function ()set zoneAwareStack: function (value)__proto__: Object
(anonymous) @ bundle.js:2
A @ bundle.js:2
(anonymous) @ bundle.js:2
ZoneDelegate.invokeTask @ zone.js:367
Zone.runTask @ zone.js:166
ZoneTask.invoke @ zone.js:420
data.args.(anonymous function) @ zone.js:1581
module.exports @ shim.js:1602
queue.(anonymous function) @ shim.js:4306
run @ shim.js:4294
listener @ shim.js:4298
&#13;
&#13;
&#13;

我的档案: enter image description here 的index.html

&#13;
&#13;
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <title>AngularTest</title>

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
	<script src="node_modules/core-js/client/shim.js"></script>
	<script src="node_modules/zone.js/dist/zone.js"></script>
	<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="systemjs.config.js"></script> 
<script>
System.import('app/js/app/main/main.js').catch(function (err) { console.error(err); });
</script>
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>
&#13;
&#13;
&#13;

systemjs.config.js

&#13;
&#13;
(function (global) {
    System.config({
    	
    	paths: {
            "npm:": "node_modules/"
        },
        map: {
            "app": "app",
            "@angular/core": "npm:@angular/core/bundles/core.umd.js",
            "@angular/common": "npm:@angular/common/bundles/common.umd.js",
            "@angular/compiler": "npm:@angular/compiler/bundles/compiler.umd.js",
            "@angular/platform-browser": "npm:@angular/platform-browser/bundles/platform-browser.umd.js",
            "@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js",
            "@angular/http": "npm:@angular/http/bundles/http.umd.js",
            "@angular/router": "npm:@angular/router/bundles/router.umd.js",
            "@angular/forms": "npm:@angular/forms/bundles/forms.umd.js",
            "rxjs": "npm:rxjs",
        },
        packageConfigPaths: ['package.json'],
        packages: {
            app: {
            	main:'./js/app/main/main.js',
                defaultExtension: "js"
            },
            rxjs: {
                defaultExtension: "js"
            }
        }
    });
})(this);
&#13;
&#13;
&#13;

polyfills.ts

&#13;
&#13;
// This file includes polyfills needed by Angular and is loaded before the app.
// You can add your own extra polyfills to this file.
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/reflect';

import 'core-js/es7/reflect';
import 'zone.js/dist/zone';
&#13;
&#13;
&#13;

的package.json

&#13;
&#13;
{
  "name": "angular-test",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.28.3",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "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.13",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.3"
  }
}
&#13;
&#13;
&#13;

0 个答案:

没有答案