2017-06-21 7 views
0

だから、nodejsを更新してからそれが起こった。角2はエラーを起こさなかったし、うまくいきましたが、現在は動作を停止したnode_modulesを更新しています。エラーがどこにあるのか、それを修正する方法はわかりません。angular 2予期しないトークンエラー

(index):29 Error: (SystemJS) Unexpected token < 
    SyntaxError: Unexpected token < 
     at eval (<anonymous>) 
     at Object.eval (http://localhost:3000/app/services/authentication.service.js:15:22) 
     at eval (http://localhost:3000/app/services/authentication.service.js:70:4) 
     at eval (http://localhost:3000/app/services/authentication.service.js:71:3) 
    Evaluating http://localhost:3000/node_modules/angular2-jwt/angular2-jwt.js 
    Evaluating http://localhost:3000/app/services/authentication.service.js 
    Evaluating http://localhost:3000/app/profile/profile.component.js 
    Evaluating http://localhost:3000/app/app.module.js 
    Evaluating http://localhost:3000/app/main.js 
    Error loading http://localhost:3000/app/main.js 
     at eval (<anonymous>) 
     at Object.eval (http://localhost:3000/app/services/authentication.service.js:15:22) 
     at eval (http://localhost:3000/app/services/authentication.service.js:70:4) 
     at eval (http://localhost:3000/app/services/authentication.service.js:71:3) 
    Evaluating http://localhost:3000/node_modules/angular2-jwt/angular2-jwt.js 
    Evaluating http://localhost:3000/app/services/authentication.service.js 
    Evaluating http://localhost:3000/app/profile/profile.component.js 
    Evaluating http://localhost:3000/app/app.module.js 
    Evaluating http://localhost:3000/app/main.js 
    Error loading http://localhost:3000/app/main.js 

systemjs.config.js

(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: 'app', 
     // 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', 
     // other libraries 
     'rxjs':      'npm:rxjs', 
     'angular2-jwt': 'node_modules/angular2-jwt/angular2-jwt.js', 
     'angular-in-memory-web-api': 'npm:angular-in-memory-web-api', 
    }, 
    // 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' 
     }, 
     'angular-in-memory-web-api': { 
     main: './index.js', 
     defaultExtension: 'js' 
     } 
    } 
    }); 
})(this); 

index.htmlを

<html> 
    <head> 
    <title>Vietnam Films</title> 
    <base href="/"> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.css"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css"> 
    <link rel="stylesheet" href="assets/ecommerce.css"> 

    <!-- 1. Load libraries --> 
    <!-- Polyfill(s) for older browsers --> 
    <script src="node_modules/core-js/client/shim.min.js"></script> 

    <script src="node_modules/zone.js/dist/zone.js"></script> 
    <script src="node_modules/reflect-metadata/Reflect.js"></script> 
    <script src="node_modules/systemjs/dist/system.src.js"></script> 

    <script src="node_modules/jquery/dist/jquery.min.js"></script> 
    <script src="node_modules/tether/dist/js/tether.min.js"></script> 
    <script src="node_modules/bootstrap/dist/js/bootstrap.js"></script> 
    <script src="https://www.paypalobjects.com/api/checkout.js"></script> 



    <!-- 2. Configure SystemJS --> 
    <script src="systemjs.config.js"></script> 
    <script> 
     System.import('app').catch(function(err){ console.error(err); }); 
    </script> 
    <script src="//cdn.auth0.com/js/lock-9.0.min.js"></script> 
    </head> 

    <!-- 3. Display the application --> 
    <body> 
    <my-app></my-app> 



    <div class="loading"> 
     <h1>Loading...</h1> 
    </div> 


    </body> 
</html> 

tsconfig.json

{ 
    "compilerOptions": { 
    "module": "commonjs", 
    "target": "es5", 
    "sourceMap": true 
    }, 
    "exclude": [ 
    "node_modules" 
    ] 
} 
+0

実際に404ファイルが見つからない可能性があります。もちろん、Angularでは404をindex.htmlページにリダイレクトすることになっています。おそらくこれは正しく動作しています。このような場合には、実際に404を返すようにWebサーバーを設定し、欠落しているファイルを確認してください。またはブラウザのdevツールでネットワークトラフィックを調べて、要求が正しいファイルではなくindex.htmlページを返すかどうかを確認します。 –

+0

私は最終的にエラーが見つかりました、クロムブラウザのコンソールがあまりにも曖昧で、私はFirefoxのコンソールを見て、私はノードモジュールが欠けていたと言いました。 –

答えて

0

開発ツールはあなたの友達です。ページにアクセスしてネットワークタブを確認している間にChrome開発ツールを開きます。個々の要求を見てください。私はhttp://localhost:3000/app/services/authentication.service.js要求があなたが望んでいるJavaScriptを返さないと推測しており、代わりにHTMLエラーページを返しています。そのエラーが何であるかを調べると、犯人が見つかります。ほとんどの場合、ファイルを見つけられないだけです(HTTP 404)が、エラーをチェックするのが最適です。

404の場合は、authentication.service.jsが提供元のapp/servicesディレクトリに正しく配置されていることを確認してください。

関連する問題