VS代码:“因未生成代码而被忽略的断点”错误 [英] VS Code: "Breakpoint ignored because generated code not found" error

查看:2679
本文介绍了VS代码:“因未生成代码而被忽略的断点”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到无处不在,我还在VS代码中调试了TypeScript。我已经阅读了



我失踪了什么?



编辑:



我还是坚持下去我设法做了一个打破点的示例项目,但是当我尝试将该项目复制到我的硬盘上的不同位置时,断点再次变成灰色,没有被击中。我在这个测试项目中做了不同的工作是通过使用 tsc app.ts --inlinesourcemap


$ b $编译TypeScript文件来使用内联源代码b

我将上述示例项目上传到GitHub,以便您可以查看此处

解决方案

我在找到一个类似的问题的解决方案时遇到这个问题。尽管与OP的问题不同,它可能会帮助别人。



上下文:我正在关注 Visual Studio代码HelloWorld示例,发现自己无法在断点上停止。



我通过更改 .vscode / launch.json ,以便启动配置下的sourceMaps:true 属性设置(默认值为false)。 / p>

I have looked everywhere and I still have issue debugging TypeScript inside VS Code. I have read this thread but still I am not able to hit my breakpoints placed inside a TypeScript file, hitting the breakpoints in .js files all works fine.

So here is the simplest "hello world" project I have set up.

  • app.ts:

    var message: string = "Hello World";
    
    console.log(message);
    

  • tsconfig.json

    {
        "compilerOptions": {
            "target": "es5",
            "sourceMap": true
        }
    }
    

  • launch.json

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Launch",
                "type": "node",
                "request": "launch",
                "program": "${workspaceRoot}/app.js",
                "stopOnEntry": false,
                "args": [],
                "cwd": "${workspaceRoot}",
                "preLaunchTask": null,
                "runtimeExecutable": null,
                "runtimeArgs": [
                    "--nolazy"
                ],
                "env": {
                    "NODE_ENV": "development"
                },
                "externalConsole": false,
                "sourceMaps": true,
                "outDir": null
            }
        ]
    }
    

I have generated the js.map files by running the tsc --sourcemap app.ts command.

After all of those steps when I set a breakpoint on the console.log(message); row and launch the program (F5) from the "Debug" tab that breakpoint is grayed out saying "Breakpoint ignored because generated code not found (source map problem?)." I attached a screenshot of what I am observing:

What am I missing?

Edit:

Hi, I am still stuck on this. I managed to make one sample project that was hitting the break points but after I tried to copy that project to a different location on my HDD the break points again became gray and were not hit. What I did different in this test project was to use inline sourcemaps by compiling the TypeScript files with tsc app.ts --inlinesourcemap

I uploaded the mentioned sample project to GitHub so you can take a look at it here.

解决方案

I came across this question while looking for a solution to a similar problem that I was having. Despite being different from OP's problem, it might help others.

Context: I was following the Visual Studio Code HelloWorld example and found myself unable to stop on break points.

I solved my problem by changing .vscode/launch.json so that "sourceMaps": true attribute under the Launch configuration was set (it starts default on false).

这篇关于VS代码:“因未生成代码而被忽略的断点”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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