2016-09-20 24 views
0

ASP.NETでJSMP、SystemJS、TS LoaderでAngular 2.0.0を試してみますMVC 5(コアではない)アプリ。モジュール '@ angular/core' '@ angular/core' @ angular/platform-b​​rowser @ angular/platform-b​​rowser-dynamic

Visual Studioは角度モジュールを見つけることに不満を持ちます。

Severity Code Description Project File Line Suppression State 
Error TS2307 Cannot find module './components/app.component'.  
Error TS2307 Cannot find module '@angular/core'. 
Error TS2307 Cannot find module '@angular/core'. 
Error TS2307 Cannot find module '@angular/platform-browser'. 
Error TS2307 Cannot find module '@angular/platform-browser-dynamic'. 

私はJSPM経由でインストールします。

tsconfig.json

{ 
    "compilerOptions": { 
    "target": "es5", 
    /* target of the compilation (es5) */ 
    "module": "system", 
    /* System.register([dependencies], function) (in JS)*/ 
    "moduleResolution": "node", 
    /* how module gets resolved (needed for Angular 2)*/ 
    "emitDecoratorMetadata": true, 
    /* needed for decorators */ 
    "experimentalDecorators": true, 
    /* needed for decorators (@Injectable) */ 
    "noImplicitAny": false 
    /* any has to be written explicity*/ 
    }, 
    "exclude": [ 
    /* since compiling these packages could take ages, we want to ignore them*/ 
    "jspm_packages", 
    "node_modules" 
    ], 
    "compileOnSave": false 
    /* on default the compiler will create js files */ 
} 

config.jsの

System.config({ 
    baseURL: "/", 
    defaultJSExtensions: true, 
    transpiler: "babel", 
    babelOptions: { 
    "optional": [ 
     "runtime", 
     "optimisation.modules.system" 
    ] 
    }, 
    typescriptOptions: { 
    "tsconfig": true 
    }, 
    paths: { 
    "github:*": "jspm_packages/github/*", 
    "npm:*": "jspm_packages/npm/*" 
    }, 

    packages: { 
    "app": { 
     "main": "bootstrap", 
     "format": "system", 
     "defaultExtensions": "ts", 
     "meta": { 
     "*.ts": { 
      "loader": "ts" 
     } 
     } 
    } 
    }, 

    map: { 
    "@angular/common": "npm:@angular/[email protected]", 
    "@angular/compiler": "npm:@angular/[email protected]", 
    "@angular/core": "npm:@angular/[email protected]", 
    "@angular/http": "npm:@angular/[email protected]", 
    "@angular/platform-browser": "npm:@angular/[email protected]", 
    "@angular/platform-browser-dynamic": "npm:@angular/[email protected]", 
    "@angular/router": "npm:@angular/[email protected]", 
    "babel": "npm:[email protected]", 
    "babel-runtime": "npm:[email protected]", 
    "core-js": "npm:[email protected]", 
    "es6-shim": "github:es-shims/[email protected]", 
    "reflect-metadata": "npm:[email protected]", 
    "rxjs": "npm:[email protected]", 
    "ts": "github:frankwallis/[email protected]", 
    "zone.js": "npm:[email protected]", 
    "github:frankwallis/[email protected]": { 
     "typescript": "npm:[email protected]" 
    }, 

    } 
}); 

app.module.ts

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

index.htmlを

<script src="../../jspm_packages/npm/[email protected]/client/shim.min.js"></script> 
    <script src="../../jspm_packages/npm/[email protected]/dist/zone.min.js"></script> 
    <script src="../../jspm_packages/npm/[email protected]/Reflect.js"></script> 
    <script src="../../jspm_packages/system.js"></script> 
    <script src="../../config.js"></script> 
    <script> 
      System.config 
      ({ 
       map: { 
        "@@angular/common": "npm:@@angular/[email protected]", 
        "@@angular/compiler": "npm:@@angular/[email protected]", 
        "@@angular/core": "npm:@@angular/[email protected]", 
        "@@angular/http": "npm:@@angular/[email protected]", 
        "@@angular/platform-browser": "npm:@@angular/[email protected]", 
        "@@angular/platform-browser-dynamic": "npm:@@angular/[email protected]", 
        "@@angular/router": "npm:@@angular/[email protected]", 
        "reflect-metadata": "npm:[email protected]" 
       }, 
       transpiler: "ts", 
       packages: 
       { 
        "app": { 
         "defaultExtension": "ts", 
         "meta": { 
          "*.ts": { 
           "loader": "ts" 
          } 
         } 
        } 
       } 
      }); 

      console.log("System.Config Init OK"); 
    </script> 

答えて

1

あなたをJSPM使用するには、あなたは、パスの設定を使用してモジュールがどこにあるか活字体と言うことができるように2.0を活字体が必要です。

tsconfig.json

{ 
 
    "compilerOptions": { 
 
     "target": "es5", 
 
     "module": "system", 
 
     "moduleResolution": "node", 
 
     "sourceMap": true, 
 
     "emitDecoratorMetadata": true, 
 
     "experimentalDecorators": true, 
 
     "removeComments": false, 
 
     "noImplicitAny": false, 
 
     "baseUrl": ".", 
 
     "paths": { 
 
      "@angular/core": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "@angular/platform-browser-dynamic": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "@angular/common": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "@angular/compiler": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "@angular/forms": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "@angular/http": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "@angular/platform-browser": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "@angular/router": [ 
 
       "jspm_packages/npm/@angular/[email protected]" 
 
      ], 
 
      "es6-shim": [ 
 
       "jspm_packages/npm/[email protected]" 
 
      ], 
 
      "reflect-metadata": [ 
 
       "jspm_packages/npm/[email protected]" 
 
      ], 
 
      "rxjs/*": [ 
 
       "jspm_packages/npm/[email protected]/*" 
 
      ], 
 
      "systemjs": [ 
 
       "jspm_packages/npm/[email protected]" 
 
      ], 
 
      "zone.js": [ 
 
       "jspm_packages/npm/[email protected]" 
 
      ] 
 
     } 
 
    }, 
 
    "exclude": [ 
 
     "node_modules", 
 
     "jspm_packages" 
 
    ] 
 
}

+0

に役立ちます。あなたはtsconfig.jsonファイルをすべて貼り付けることができますか? – rco

+0

完全なtsconfig.jsonで答えを編集しました。 typescriptのバージョン2.0を使用してコンパイルしているかどうか確認できますか? 「パス」機能は2.0で追加されただけです。 http://stackoverflow.com/questions/32385087/vs2015-change-typescript-version –

1

フォルダが 'node_modules' を確認してください(隠しファイルをクリック)右の場所(プロジェクトのルートに、wwwrootのと兄弟)です。 また@angularがプロジェクトに表示されてチェックするフォルダ依存性:

[。projの名前] /依存関係/ NPM/@角度...)。

クイックスタートガイドを新しいASP.NETコアプロジェクトに統合していたときにファイルを移動していました(私はあなたのコアではないが、まさにそのケースを知っています)、node_modulesフォルダが間違っていました。

希望は、これは私がtsconfig.jsonが、同じエラーを編集できますが、フィードバックをありがとうございました

関連する問題