未捕获的SyntaxError:意外的令牌< VM105:17未捕获的ReferenceError:未定义系统

时间:2016-02-24 08:25:59

标签: javascript node.js angular systemjs

我从nodejs服务器提供我的index.html。这个ng2文件适用于实时服务器。但是当我从具有特定路由的nodejs index.js加载它时,会出现以下错误。

Uncaught SyntaxError: Unexpected token <
VM105:17Uncaught ReferenceError: System is not defined

我已正确加载文件。以下是加载的文件:

<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.33.3/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.16/system-polyfills.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.min.js"></script>
<script src="node_modules/angular2/bundles/angular2.min.js"></script>
<script src="node_modules/angular2/bundles/router.js"></script>
<script src="node_modules/angular2/bundles/http.js"></script>

<!-- 2. Configure SystemJS and Import -->
<script>
    System.config({
    packages: {        
      client: {
        format: 'register',
        defaultExtension: 'js'
      }
    }
  });
  System.import('client/boot')
        .then(null, console.error.bind(console));
</script>

我错过了什么?所有文件都是从节点服务器提供的。

1 个答案:

答案 0 :(得分:2)

大多数情况下,如果您收到错误Uncaught SyntaxError: Unexpected token <,则表示script元素中引用的文件存在404错误。

我认为您的节​​点服务无法提供您的node_modules文件夹。因此无法加载node_modules/systemjs/dist/system.src.js文件(node_modules中的其他文件也是如此)。

相关问题