Angular2 + webpack未捕获ReferenceError:系统未定义

编程入门 行业动态 更新时间:2024-10-26 18:16:25
本文介绍了Angular2 + webpack未捕获ReferenceError:系统未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我遇到了同样的问题: 为什么将webpack捆绑为"System.register"

I've got the same issue like here: Why webpack bundled as 'System.register'

我已经使用webpack构建bundle.js,但出现错误:

I've build bundle.js with webpack and I am getting error:

未捕获的ReferenceError:系统未定义

Uncaught ReferenceError: System is not defined

我的bundle.js包括:

my bundle.js inlcudes:

System.register(['angular2/platform/browser', './appponent', 'rxjs/Rx'], function(exports_1, context_1) { "use strict"; var __moduleName = context_1 && context_1.id; var browser_1, app_component_1; return { setters:[ function (browser_1_1) { browser_1 = browser_1_1; }, function (app_component_1_1) { app_component_1 = app_component_1_1; }, function (_1) {}], execute: function() { //enableProdMode(); browser_1.bootstrap(app_component_1.AppComponent) .then(function (success) { return console.log("Bootstrap success"); }) .catch(function (error) { return console.log(error); }); } } });

我已经在tsconfig.json中将模块更改为commonjs,所以在某处可能是一些愚蠢的错误.这是我的tsconfig.json

I've already changed module to commonjs in tsconfig.json, so it's probably some silly mistake somewhere. Here is my tsconfig.json

{ "compilerOptions": { "emitDecoratorMetadata": true, "experimentalDecorators": true, "target": "es5", "module": "commonjs", "removeComments": true, "sourceMap": false }, "exclude": [ "node_modules" ] }

和webpack.config.js

and webpack.config.js

module.exports = { entry: "./app/main", output: { filename: "bundle.js" }, resolve: { extensions: ['', '.js', '.ts'] }, module: { loaders: [{ test: /\.ts/, loaders: ['ts-loader'], exclude: /node_modules/ }] } };

感谢您的帮助

推荐答案

将tsconfig.json的compilerOptions中的module更改为commonjs.

Change module to commonjs in compilerOptions of your tsconfig.json.

更多推荐

Angular2 + webpack未捕获ReferenceError:系统未定义

本文发布于:2023-11-22 23:16:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619303.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:未定义   系统   webpack   ReferenceError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!