gpt4 book ai didi

javascript - 网络 Storm : debugging typescript

转载 作者:行者123 更新时间:2023-11-28 18:39:50 25 4
gpt4 key购买 nike

问题已更新。请检查编辑情况

我想使用 Webstorm 中包含的调试器来运行我的项目。我是使用 Angular2 和 TypeScript。我需要在我的 typescript 文件中放置断点。

基本上,我的 index.html 只是导入一些 .js 文件并启动我的应用程序通过调用另一个 .js 文件中定义的名为 bootstrap 的函数(从 .ts 文件转换而来!)。

<!DOCTYPE html>
<html lang="en">
<head>
<base href="/">
<meta charset="UTF-8">
<title></title>

<!-- 1. Load libraries -->
<!-- IE required polyfills, in this exact order -->
<script src="../node_modules/es6-shim/es6-shim.min.js"></script>
<script src="../node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="../node_modules/angular2/es6/dev/src/testing/shims_for_IE.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.js"></script>
<script src="../node_modules/angular2/bundles/angular2.dev.js"></script>

<script src="build/core/system.config.js"></script>
<script src="build/core/moduleLoader.js"></script>
<script src="build/core/bootstrap.js"></script>
<script src="../node_modules/angular2/bundles/router.dev.js"></script>

<script>
bootstrap();
</script>
</head>
<body>

<app-view>Loading...</app-view>

</body>
</html>

bootstrap 定义如下:

const bootstrap:()=>Promise<void>= async function() {
await ModuleLoader.loadAll();
System.import('core/app').then(null, console.error.bind(console));
};

window.bootstrap = bootstrap;

当我在 Debug模式下运行index.html时,会抛出错误,bootstrap() 未定义。

当我在浏览器中运行该应用程序时,它运行良好。我错过了一些配置吗?

我已经安装了jetbrains插件(我使用的是chrome)并配置了端口。我可以在浏览器上看到“正在加载...”。

<小时/>

编辑

也许有用的信息:

我正在使用节点。在我的主服务器端脚本中,我设置了 express 并进行了一些配置。当我尝试调试时,我的服务器正在监听,但在另一个端口(8080)上。调试器使用端口 63343。

最佳答案

您可以为任何 URL 启动 JavaScript 调试 session - 您只需在 JavaScript 运行配置中指定它即可。如果您的应用在 localhost:8080 上运行,则在 JavaScript 调试配置中使用该 URL。

enter image description here

另一个重要点:确保在编译 TypeScript 代码时生成源映射。

关于javascript - 网络 Storm : debugging typescript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36312373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com