0

Uncaught (in promise) 错误:SyntaxError: Unexpected token <(...) in system.src.js 尝试使用升级适配器同时运行 angular1 和 angular2 时。

我使用https://angular.io/docs/ts/latest/guide/upgrade.html作为参考。

systemjs.config.js

var map = {
'app':                        '/app', // 'dist',
'@angular':                   '/node_modules/@angular',
'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
'rxjs':                       '/node_modules/rxjs'
};
var packages = {
'/app':                       { main: 'main.js',  defaultExtension: 'js' },
'rxjs':                       { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
};

System.import('app/main');

索引.html

<!doctype html>

    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="apple-mobile-web-app-title" content="UpToDate" />
    <meta name="format-detection" content="telephone=no" />
    <link href="/app/assets/utd-icon.png" rel="apple-touch-icon" />
    <meta name="fragment" content="!" />
    <link rel="canonical" href="{{configCtrl2.info.canonicalUrl}}"/>
    <meta name="description" content="{{configCtrl2.info.metaDescription}}"/>
    <meta charset="UTF-8"/>

    <style type="text/css">
        #appContainer {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background: url(/app/assets/utd-menu/utd-icon.png) no-repeat;
            background-attachment: fixed;
            background-position: center;
            background-size: 48px 48px;
        }
    </style>




    <!-- inject:app:css --><link rel="stylesheet" href="/app/assets/app-a9ca3a4af9.css"><!-- endinject -->
    <!-- inject:pace:js --><script src="/app/dist/pace-fe9335c2fc.min.js"></script><!-- endinject -->



    <!-- inject:system:js --><script src="/app/dist/system.src.js"></script><!-- endinject -->


    <!-- inject:router:js --><script src="/app/dist/router.dev.min.js"></script><!-- endinject -->
    <!-- inject:http:js --><script src="/app/dist/http.dev.min.js"></script><!-- endinject -->


    <!-- inject:systemjs:js --><script src="/app/dist/systemjs.config.js"></script><!-- endinject -->

    <base href="/index.html">

</head>

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

main.ts

import { bootstrap }    from '@angular/platform-browser-dynamic';
import { AppComponent } from './app/app.component.ts';
bootstrap(AppComponent);

升级适配器.ts

import { UpgradeAdapter} from '@angular/upgrade';

export const upgradeAdapter = new UpgradeAdapter();

我几乎尝试了所有方法并按照升级练习的说明进行操作,但我似乎无法摆脱这个错误。

system.src.js:1 Uncaught (in promise) Error: SyntaxError: Unexpected token <(…)

system.src.js:1 Uncaught (in promise) Error: SyntaxError: Unexpected token <(…)

索引页面加载时加载...

文件结构

app
|
|__components
|__dist
|    |___systemjs.config.js
|    |___system.src.js
|
|__index.html
|__main.ts
4

0 回答 0