2016-07-05 1 views
1

アプリケーションが読み込まれると、次のエラーが発生します。@ angle/platform-b​​rowser-dynamicを読み込めません

http://localhost:49769/node_modules/@angular/platform-browser-dynamic/index.js Failed to load resource: the server responded with a status of 404 (Not Found) 
localhost/:21 Error: Error: XHR error (404 Not Found) loading http://localhost:49769/node_modules/@angular/platform-browser-dynamic/index.js 
     at XMLHttpRequest.wrapFn [as _onreadystatechange] (https://npmcdn.com/[email protected]?main=browser:769:30) 
     at ZoneDelegate.invokeTask (https://npmcdn.com/[email protected]?main=browser:356:38) 
     at Zone.runTask (https://npmcdn.com/[email protected]?main=browser:256:48) 
     at XMLHttpRequest.ZoneTask.invoke (https://npmcdn.com/[email protected]?main=browser:423:34) 
    Error loading http://localhost:49769/node_modules/@angular/platform-browser-dynamic/index.js as "@angular/platform-browser-dynamic" from http://localhost:49769/app/main.js(anonymous function) @ localhost/:21 
http://localhost:49769/node_modules/@angular/core/index.js Failed to load resource: the server responded with a status of 404 (Not Found) 

私のプロジェクトにconfigファイルと.tsファイルを置くフォルダ構造を見てください。ファイルが正しいフォルダenter image description here

Package.json

{ 
    "name": "Testing", 
    "version": "1.0.0", 
    "scripts": { 
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "lint": "tslint ./app/**/*.ts -t verbose", 
    "lite": "lite-server", 
    "typings": "typings", 
    "postinstall": "typings install" 
    }, 
    "license": "ISC", 
    "dependencies": { 
    "@angular/common": "2.0.0-rc.4", 
    "@angular/compiler": "2.0.0-rc.4", 
    "@angular/core": "2.0.0-rc.4", 
    "@angular/forms": "0.2.0", 
    "@angular/http": "2.0.0-rc.4", 
    "@angular/platform-browser": "2.0.0-rc.4", 
    "@angular/platform-browser-dynamic": "2.0.0-rc.4", 
    "@angular/router": "3.0.0-beta.2", 

    "systemjs": "0.19.27", 
    "core-js": "^2.4.0", 
    "reflect-metadata": "^0.1.3", 
    "rxjs": "5.0.0-beta.6", 
    "zone.js": "^0.6.12", 

    "bootstrap": "^3.3.6" 
    }, 
    "devDependencies": { 
    "concurrently": "^2.0.0", 
    "lite-server": "^2.2.0", 
    "tslint": "^3.7.4", 
    "typescript": "^1.8.10", 
    "typings": "^1.0.4" 
    }, 
    "repository": { } 
} 

systemjs.config.js

{ 
    "compilerOptions": { 
    "target": "es6", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
    } 
} 

なぜアプリケーションtsconfig.json

/** 
* System configuration for Angular 2 samples 
* Adjust as necessary for your application needs. 
*/ 
(function (global) { 

    // map tells the System loader where to look for things 
    var map = { 
     'app': 'app', 
     'rxjs': 'node_modules/rxjs', 
     '@angular': 'node_modules/@angular' 

    }; 

    // packages tells the System loader how to load when no filename and/or no extension 
    var packages = { 
     'app': { main: 'main.js', defaultExtension: 'js' }, 
     'rxjs': { defaultExtension: 'js' }, 

     '@angular/common': { defaultExtension: 'js', main: 'index.js' }, 
     '@angular/compiler': { defaultExtension: 'js', main: 'index.js' }, 
     '@angular/core': { defaultExtension: 'js', main: 'index.js' }, 
     '@angular/http': { defaultExtension: 'js', main: 'index.js' }, 
     '@angular/platform-browser': { defaultExtension: 'js', main: 'index.js' }, 
     '@angular/platform-browser-dynamic': { defaultExtension: 'js', main: 'index.js' }, 
     '@angular/router': { defaultExtension: 'js', main: 'index.js' }, 

    }; 

    var packageNames = [ 
     '@angular/common', 
     '@angular/compiler', 
     '@angular/core', 
     '@angular/forms', 
     '@angular/http', 
     '@angular/platform-browser', 
     '@angular/platform-browser-dynamic', 
     '@angular/router' 
    ]; 

    // add package entries for angular packages in the form 
    // '@angular/common': { main: 'index.js', defaultExtension: 'js' } 
    packageNames.forEach(function (pkgName) { 
     packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; 
    }); 

    var config = { 
     map: map, 
     packages: packages 
    }; 

    System.config(config); 

})(this); 

に配置されているかどうかを検証してください。 node_modulesの下でplatform-b​​rowser-dynamicを読み込めませんか?指定したフォルダの下にファイルが存在することを確認しましたが、まだこのエラーが発生しています。

注:NPM /依存関係のフォルダは、「インストールしない」と言っているが、私はフォルダを展開し、すべての参照が正しくインストールされていることに気付くことができますが、まだそれはこのエラー/警告メッセージを表示し

+0

は、IDEを再起動しようとする必要がありますか? – maxisam

+0

は何度も試してみましたが、他の提案はありませんか? – Krishnan

+0

node_modulesディレクトリ全体を吹き飛ばし、 'npm install'をもう一度実行してみてください。それでも問題が解決しない場合は、アンケートチームのgithubページにバグレポートを提出してください。あなたの設定ファイルとpackage.jsonはうまく見えますので、環境を複製せずに何が起きているのか、問題を再現するのは難しいことは明らかではありません。 – BrianRT

答えて

3

ますwwwrootからnode_modulesをインポートすることはできませんが、wwwrootの宛先フォルダにバンドルをコピーする必要があります(例:gulp)。systemjs.config.jsでインポートしてください。 systemjs.config.jsの位置はwwwrootで正しいです。

私はあなたがこのようないくつかの例を、従うお勧め:https://github.com/ajtowf/aspnetcore-angular2-seed

関連する問題