我的第一个简单的Angular v2.3.1应用程序中出现奇怪的错误

时间:2016-12-18 15:13:01

标签: macos angular typescript

我有错误'潜在的未处理拒绝[1] NgZone 尝试在Mac OS x上的Safari中启动我的简单angular2应用程序时,_bootstrapModuleFactoryWithZone'。

堆栈跟踪:

Potentially unhandled rejection [1] NgZone
_bootstrapModuleFactoryWithZone
F@http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js:4:7488
H@http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js:4:7117
when@http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js:4:10788
run@http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js:4:9827
_drain@http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js:4:1747
drain@http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js:4:1404
e@http://localhost:3000/node_modules/systemjs/dist/system-polyfills.js:4:3320

我的应用程序在GitHub上:https://github.com/netmajor/Angular2/tree/master/angular2-seed

的package.json

    {
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "typings": "typings",
    "postinstall": "typings install"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.3.x",
    "@angular/compiler": "2.3.x",
    "@angular/core": "2.3.x",
    "@angular/forms": "2.3.x",
    "@angular/http": "2.3.x",
    "@angular/platform-browser": "2.3.x",
    "@angular/platform-browser-dynamic": "2.3.x",
    "@angular/platform-server": "2.3.x",
    "@angular/router": "3.3.x",
    "@angular/upgrade": "^2.3.1",
    "core-js": "^2.4.1",
    "es6-promise": "^4.0.5",
    "es6-shim": "^0.35.2",
    "reflect-metadata": "^0.1.8",
    "rxjs": "5.0.0-rc.4",
    "systemjs": "^0.19.41",
    "ts-helpers": "^1.1.2",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "concurrently": "^3.1.0",
    "gulp": "^3.9.1",
    "lite-server": "^2.2.2",
    "q": "^1.4.1",
    "reflect-metadata": "^0.1.8",
    "rimraf": "^2.5.4",
    "systemjs-builder": "^0.15.34",
    "typescript": "^2.1.4"
  }
}

的index.html

<html>

<head>
    <title>Angular 2 QuickStart</title>

    <!-- 1. Load libraries -->
    <!-- IE required polyfills, in this exact order -->
    <script src="node_modules/es6-shim/es6-shim.min.js"></script>
    <script src="node_modules/systemjs/dist/system-polyfills.js"></script>


    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/.tmp/Rx.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>

    <!-- 2. Configure SystemJS -->
    <script>
        System.config({
            paths: {
                // paths serve as alias
                'npm:': 'node_modules/'
            },
            map: {
                // our app is within the app folder
                app: 'app',

                // angular bundles
                '@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',

                // other libraries
            },

            packages: {
                app: {
                    format: 'register',
                    defaultExtension: 'js'
                }
            },

        });
        System.import('app/main')
            .then(null, console.error.bind(console));
    </script>

</head>

<!-- 3. Display the application -->

<body>
    <my-app>Loading...</my-app>
</body>

</html>

请帮忙

1 个答案:

答案 0 :(得分:1)

我用的是cli。现在它工作;)