2016-12-14 2 views
1

私が取り組んでいるログインコンポーネントをテストするために、Angular2アプリケーションの一部としてmockBackendを使用しています。私は、ログイン作業のスタンドアロンバージョンを持っています。しかし、私が試してみて、すでに開発中のアプリに組み込んでみると、私は問題にぶつかっています。具体的には、コンパイル時に、私のファイルのいくつかが「dist」フォルダに配置され、Angularがそれらを見つけることができなくなっているようです。なぜこれが起こっているのか分かりません。探し「Dist」フォルダに配置されているファイルが誤って配置され、Angular 2 Appを破る

http://localhost:3000/node_modules/@angular/http/bundles/http.umd.js/testing 404 (Not Found) 

私は「DIST」ファイル内の私のnode_modulesで見ると案の定、私は「テスト」フォルダがある見るが、それは正確ではありませんどこ角さん:ここで私は私のコンソールに表示されるエラーですそれ。

数週間前の私のsocket.io "dist"の場所と同様の問題だと思っていました。正しい場所を指すように手動でsystemjs.config.jsファイルを調整しなければなりませんでした。その後、それは働いた。この場合、私は再び何をする必要があるのでしょうか? "dist"フォルダへのコンパイルでこれが起こったような誤った場所があると、どうすればいいですか?

ところで、私は現在、角度2.0.0を使用しています。

/** 
* SystemJS configuration file. 
*/ 
(function(global) 
{ 
    System.config({ 
     paths: { 
      // paths serve as alias 
      'npm:': 'node_modules/' 
     }, 
     // map tells the System loader where to look for things 
     map: { 
      // our app is within the app folder 
      app: 'dist', 
      // 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', 
      /*'@angular/material': 'npm:@angular/material/material.umd.js',*/ 
      // other libraries 
      'rxjs': 'npm:rxjs', 
      'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api', 
      // 'socket.io-client': 'npm:/socket.io-client/socket.io.js', 
      'socket.io-client': 'node_modules/socket.io/node_modules/socket.io-client/socket.io.js', 
      // 'socket.io-client': 'dist/node_modules/socket.io/node_modules/socket.io-client/socket.io.js', 
      'angular2-chartjs': 'npm:angular2-chartjs', 
      'chart.js': 'npm:chart.js/dist/Chart.bundle.js' 
     }, 
     // packages tells the System loader how to load when no filename and/or no extension 
     packages: { 
      app: {main: './main.js', defaultExtension: 'js'}, 
      rxjs: {defaultExtension: 'js'}, 
      'angular2-in-memory-web-api': {main: './index.js', defaultExtension: 'js'}, 
      'socket.io-client': {'defaultExtension': 'js'}, 
      'angular2-chartjs': {main: './dist/index.js', defaultExtension: 'js'} 
     } 
    }); 
})(this); 

そして、ここに私のpackage.jsonです:ここで

は私systemjs.config.jsの内容は次のようになります。

{ 
    "name": "abc", 
    "version": "0.0.1", 
    "scripts": { 
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ", 
    "lite": "lite-server", 
    "postinstall": "typings install", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "typings": "typings", 
    "docs": "typedoc --experimentalDecorators --out docs/ app/ --target 'es5' -module 'system' --ignoreCompilerErrors", 
    "clean": "del /q dist", 
    "browserify": "^13.0.1", 
    "uglifyjs": "^2.4.10", 
    "minify": "uglifyjs dist/main.min.js --screw-ie8 --compress --mangle --output dist/main.min.js", 
    "build": "npm run clean && tsc", 
    "build_prod": "npm run build && browserify -s main dist/main.js > dist/main.min.js && npm run minify" 
    }, 
    "license": "ISC", 
    "dependencies": { 
    "@angular/common": "^2.0.0", 
    "@angular/compiler": "^2.0.0", 
    "@angular/core": "^2.0.0", 
    "@angular/forms": "^2.0.0", 
    "@angular/http": "^2.0.0", 
    "@angular/platform-browser": "^2.0.0", 
    "@angular/platform-browser-dynamic": "^2.0.0", 
    "@angular/router": "^3.0.0", 
    "angular-in-memory-web-api": "~0.1.15", 
    "angular2-chartjs": "^0.1.6", 
    "bootstrap": "^3.3.6", 
    "core-js": "^2.4.1", 
    "ng2-charts": "^1.4.1", 
    "reflect-metadata": "^0.1.3", 
    "rxjs": "5.0.0-beta.12", 
    "socket.io-client": "^1.4.8", 
    "systemjs": "0.19.27", 
    "zone.js": "^0.6.23" 
    }, 
    "devDependencies": { 
    "browserify": "^13.0.1", 
    "concurrently": "^2.2.0", 
    "jasmine-core": "^2.5.2", 
    "karma": "^1.3.0", 
    "karma-chrome-launcher": "^2.0.0", 
    "karma-jasmine": "^1.0.2", 
    "lite-server": "^2.2.2", 
    "typescript": "^2.0.2", 
    "typings": "^1.3.2", 
    "uglifyjs": "^2.4.10" 
    } 
} 

答えて

1

だから私は解像度を見つけました。

「角度/ HTTP /テスト@」:予想通りその後'npm:@angular/http/bundles/http-testing.umd.js'

を、すべてが働いていた私は手動で私のsystemjs.config.jsファイルに次の行を追加する必要がありました。

関連する問題