错误:语法错误:意外的令牌< [英] Error: SyntaxError: Unexpected token <

查看:139
本文介绍了错误:语法错误:意外的令牌<的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载应用程序时出现此错误.我已经提到了路由器参考:3.0.0-beta.1

I am getting this error when I load the application. I have referred the router references : 3.0.0-beta.1

加载应用程序时浏览器控制台中的错误

The error in the browser console on the loading of the application

index.html:24 Error: SyntaxError: Unexpected token <
        at Object.eval (http://localhost:49928/app/main.js:7:36)
        at eval (http://localhost:49928/app/main.js:14:4)
        at eval (http://localhost:49928/app/main.js:15:3)
    Evaluating http://localhost:49928/lib/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js
    Evaluating http://localhost:49928/app/main.js
    Error loading http://localhost:49928/app/main.js

在错误消息中,它指出评估 wwwroot/lib/@ angular/platform中-browser-dynamic 文件夹中不存在* .umd.js文件.如何在该位置获取此文件?

In the error message it states that "Evaluating http://localhost:49928/lib/@angular/platform-browser-dynamic/platform-browser-dynamic.umd.js", but in my wwwroot/lib/@angular/platform-browser-dynamic folder there is no *.umd.js file exists. How do I get this file in that location?

我的菜单路由器提供程序组件

My menu router provider component

import { provideRouter, RouterConfig } from '@angular/router';

import { AboutComponent} from './About';
import { AboutHomeComponent } from './AboutHome';
import { AboutItemComponent } from './AboutItem';
import { HomeComponent } from './Home';

export const routes: RouterConfig = [
    { path: '', component: HomeComponent },
    {
            path: 'about',
            component: AboutComponent,
            children: [
                { path: '', component: AboutHomeComponent },
                { path: 'item/:id', component: AboutItemComponent }
            ]
        }
];

export const APP_ROUTER_PROVIDERS = [
    provideRouter(routes)
];

我的package.json是

My package.json is

{
  "name": "Firebolkt",
  "version": "1.0.0",
  "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@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.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.1",
    "@angular/forms": "0.2.0",
    "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": {
    "gulp": "^3.9.1",
    "q": "^1.4.1",
    "rimraf": "^2.5.2"
  }
}

我的systemjs.config.js

My systemjs.config.js

(function (global) {
    // map tells the System loader where to look for things
    var map = {
        'app': 'app', // 'dist',
        '@angular': 'lib/@angular',
        'rxjs': 'lib/rxjs'
    };
    // 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' }
    };
    var ngPackageNames = [
      'common',
      'compiler',
      'core',
      'http',
      'platform-browser',
      'platform-browser-dynamic',
      'router',
      'router-deprecated',
      'upgrade',
    ];
    // Add package entries for angular packages
    ngPackageNames.forEach(function (pkgName) {
        packages['@angular/' + pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
    });
    var config = {
        map: map,
        packages: packages
    }
    System.config(config);
})(this);

我什至尝试清除node_modules和wwwroot/lib文件夹并再次执行,但仍然遇到相同的错误.任何想法为什么我会收到此错误?

I even tried clearing the node_modules and wwwroot/lib folders and executed again, still I am getting the same error. any ideas why I am getting this error?

推荐答案

您收到错误,因为它尝试解析html 404响应.

You get the error, because it tries to parse a html 404 response.

您的systemJS配置已损坏.所有* .uml.js文件都位于bundles文件夹中.因此,您必须在函数中添加bundles路径:

Your systemJS config is broken. all the *.uml.js files are inside a bundles folder. So you have to add the bundles path in your function:

packages['@angular/' + pkgName] = { main: 'bundle/'+ pkgName + '.umd.js', defaultExtension: 'js' };

这篇关于错误:语法错误:意外的令牌&lt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆