未捕获的SyntaxError:意外的标记<VM105:17未引用错误:系统未定义
我正在从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>
我错过了什么? 所有文件都从节点服务器提供。
大多数情况下,当你有错误Uncaught SyntaxError: Unexpected token <
,这意味着在script
元素中引用的文件有404错误。
我认为你的Node服务不提供你的node_modules
文件夹。 因此无法加载node_modules/systemjs/dist/system.src.js
文件(对于node_modules
其他文件也是如此)。