2017-05-12 12 views
1

Chromeブラウザのコンソールに上記のエラーが表示されています。TypeError:Angular2のnullのプロパティ 'index'を読み取ることができません。

ERROR TypeError: Cannot read property 'index' of null 
    at ComponentFactory_.create (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:9896:101) 
    at ComponentFactoryBoundToModule.create (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:3434:29) 
    at ApplicationRef_.bootstrap (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:5017:57) 
    at eval (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:4806:79) 
    at Array.forEach (native) 
    at PlatformRef_._moduleDoBootstrap (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:4806:42) 
    at eval (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:4768:27) 
    at ZoneDelegate.invoke (http://localhost:63770/node_modules/zone.js/dist/zone.js:365:26) 
    at Object.onInvoke (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:4135:37) 
    at ZoneDelegate.invoke (http://localhost:63770/node_modules/zone.js/dist/zone.js:364:32) 
    at Zone.run (http://localhost:63770/node_modules/zone.js/dist/zone.js:125:43) 
    at http://localhost:63770/node_modules/zone.js/dist/zone.js:758:57 
    at ZoneDelegate.invokeTask (http://localhost:63770/node_modules/zone.js/dist/zone.js:398:31) 
    at Object.onInvokeTask (http://localhost:63770/node_modules/@angular/core/bundles/core.umd.js:4126:37) 
    at ZoneDelegate.invokeTask (http://localhost:63770/node_modules/zone.js/dist/zone.js:397:36) 

マイapp.module.tsはこれです:

import { NgModule } from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { GPAEnterpriseAppComponent } from './gpaenterprise-app.component'; 
@NgModule({ 
    imports: [ 
     BrowserModule 
    ], 
    declarations: [ 
     GPAEnterpriseAppComponent 
    ], 
    providers: [], 
    bootstrap: [GPAEnterpriseAppComponent] 
}) 
export class AppModule { } 

参照アプリケーションコンポーネントは次のようになります。

import { Component } from '@angular/core'; 
@Component({ 
    selector: 'gpa-enterprise-app', 
    template: '<h1>We are here</h1>' 
}) 
export class GPAEnterpriseAppComponent { 
} 

私は知らない、完全なスタックトレースは次のようになりますそれが必要な場合はここにパッケージです.json:

"version": "1.0.0", 
    "name": "gpa_enterprise", 
    "private": true, 
    "devDependencies": { 
    "gulp": "^3.9.1", 
    "typescript": "^2.3.2", 
    "typings": "^2.1.1" 
    }, 
    "dependencies": { 
    "@angular/animations": "^4.1.2", 
    "@angular/common": "^4.1.2", 
    "@angular/compiler": "^4.1.2", 
    "@angular/core": "^4.1.2", 
    "@angular/forms": "^4.1.2", 
    "@angular/http": "^4.1.2", 
    "@angular/material": "^2.0.0-beta.3", 
    "@angular/platform-browser": "^4.1.2", 
    "@angular/platform-browser-dynamic": "^4.1.2", 
    "@angular/router": "^4.1.2", 
    "@angular/upgrade": "^4.1.2", 
    "angular2-in-memory-web-api": "^0.0.21", 
    "core-js": "^2.4.1", 
    "primeng": "^4.0.0", 
    "reflect-metadata": "^0.1.10", 
    "rxjs": "^5.4.0", 
    "systemjs": "^0.20.12", 
    "zone.js": "^0.8.10" 
    }, 
    "scripts": { 
    "postinstall": "typings install", 
    "typings": "typings", 
    "cmd": "npm typescript" 
    } 
} 

.csproj typescriptです構成に、要求通り:.csprojファイルと

<PropertyGroup> 
    <TypeScriptToolsVersion>1.8</TypeScriptToolsVersion> 
    <TypeScriptRemoveComments>false</TypeScriptRemoveComments> 
    <TypeScriptSourceMap>true</TypeScriptSourceMap> 
    <TypeScriptTarget>ES5</TypeScriptTarget> 
    <TypeScriptJSXEmit>None</TypeScriptJSXEmit> 
    <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled> 
    <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> 
    <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny> 
    <TypeScriptModuleKind>System</TypeScriptModuleKind> 
    <TypeScriptOutFile /> 
    <TypeScriptOutDir /> 
    <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations> 
    <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError> 
    <TypeScriptMapRoot /> 
    <TypeScriptSourceRoot /> 
    <TypeScriptExperimentalDecorators>True</TypeScriptExperimentalDecorators> 
    <TypeScriptEmitDecoratorMetadata>True</TypeScriptEmitDecoratorMetadata> 
    </PropertyGroup> 
+1

これはあなたのビルドの問題かもしれないと思います。あなたはあなたのtsconfig.jsonを投稿できますか? – stevenvanc

+0

私はtsconfig.jsonを使用していません。私はtypescriptを設定するために.csprojファイルを使用しました。私はそこから関連行を掲載する予定です。 – OCDDev

+0

トピックはありませんが、タイピングをインストールしています。 は、インストールされているディレクトリに設定する必要があります。 (私は[project-root]/typings /です)ので、彼らは拾われます。 – stevenvanc

答えて

1

.csprojは

<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>, 

を持っていたが、私は2.3に更新されていました。これを反映するように上記の行を変更すると、私が受け取っていたエラーが修正されました。

+1

ああ、うれしい方向にあなたを置くことができてうれしい;) – stevenvanc

+0

私も!そのようなあいまいな誤りでした。あなたが私のtsconfigについて私に尋ねなかったなら、私はそれを見つけただろうと確信していません。 :) – OCDDev

+0

あなた自身の答えを受け入れるべきです。そうすれば、「答えた」と表示されます。 – stevenvanc

0

本当に慣れていないが、私は、彼らがのTSconfigとして機能数えます。私は設定しようとします:

<TypeScriptModuleKind>es2015</TypeScriptModuleKind> 

あなたのIDEのためにそれをキャップする必要があるか分からない。

関連する問題