2017-06-26 16 views
0

私のホストにサンプルの角度2のアプリを配備しようとしています。私はhttps://angular.io/guide/deploymentのようなことをすべてやっているし、localhostでこのアプリケーションを実行しているときにはすべてが大丈夫です。配備後のエラー角度2のアプリ

しかし、私は、私は、ブラウザのコンソールでエラーを取得していますホスティングにすべてのファイルを置くとき:

<!DOCTYPE html> 
<html> 
    <head> 
    <!-- Doesn't load from node_modules! --> 

    <!-- Set the base href --> 
    <base href="/"> 
    <title>Simple Deployment</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="styles.css"> 

    <!-- Polyfills --> 
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script> 

    <!-- Update these package versions as needed --> 
    <script src="https://unpkg.com/[email protected]?main=browser"></script> 
    <script src="https://unpkg.com/[email protected]/dist/system.src.js"> </script> 

    <!-- This SystemJS configuration loads umd packages from the web --> 
    <script src="systemjs.config.server.js"></script> 

    <script> 
     System.import('main.js') 
      .catch(function(err){ console.error(err); }); 
    </script> 
    </head> 

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

</html> 

そしてsystemjs.configファイル:

ここ
Error: (SystemJS) Unexpected token < 
SyntaxError: Unexpected token < 
    at eval (<anonymous>) 
    at ZoneDelegate.invoke (https://unpkg.com/[email protected]?main=browser:365:26) 
    at Zone.run (https://unpkg.com/[email protected]?main=browser:125:43) 
    at https://unpkg.com/[email protected]?main=browser:760:57 
    at ZoneDelegate.invokeTask (https://unpkg.com/[email protected]?main=browser:398:31) 

は私のindex.htmlファイルであります

/** 
* System configuration for Angular samples 
* Adjust as necessary for your application needs. 
*/ 
(function (global) { 
    System.config({ 
    paths: { 
     'npm:': 'https://unpkg.com/' // path serves as alias 
    }, 
    // map tells the System loader where to look for things 
    map: { 
     // our app is within the app folder 
     'app': 'app', 

     // angular bundles 
     '@angular/core': 'npm:@angular/core/bundles/core.umd.min.js', 
     '@angular/common': 'npm:@angular/common/bundles/common.umd.min.js', 
     '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.min.js', 
     '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.min.js', 
     '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.min.js', 
     '@angular/http': 'npm:@angular/http/bundles/http.umd.min.js', 
     '@angular/router': 'npm:@angular/router/bundles/router.umd.min.js', 
     '@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.min.js', 
     '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.min.js', 
     '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.min.js', 
     '@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.min.js', 

     // other libraries 
     'rxjs':      'npm:rxjs', 
     'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js' 
    }, 
    // packages tells the System loader how to load when no filename and/or no extension 
    packages: { 
     app: { 
     defaultExtension: 'js', 
     meta: { 
      './*.js': { 
      loader: 'systemjs-angular-loader.js' 
      } 
     } 
     }, 
     rxjs: { 
     defaultExtension: 'js' 
     } 
    } 
    }); 
})(this); 

これらのファイルを変更しようとしましたが、効果がありませんでした。私はindex.htmlのファイルからこの行を削除すると、私はすべてのエラーを得ることはありませんが、もちろんページがロードされていません。

<script src="systemjs.config.server.js"></script> 

<script> 
    System.import('main.js') 
     .catch(function(err){ console.error(err); }); 
</script> 

答えて

0

[OK]を、私はこの問題の解決策を見つけました。

私は、hrefのルートフォルダと変更されたベースに、私のindex.htmlファイルを移動:

<base href="/src/app">