【问题标题】:VSCode Debug and Jest: No breakpoints running with npm, CWD error running with nodeVSCode 调试和玩笑:使用 npm 运行没有断点,使用节点运行 CWD 错误
【发布时间】:2019-03-28 16:45:47
【问题描述】:

我正在尝试在 Jest Debug for VS Code 中设置断点。

此启动配置运行但未命中断点:

{
    "type": "node",
    "request": "launch",
    "name": "Test",
    "runtimeExecutable": "npm",
    "runtimeArgs": ["test"],
    "port": 9229
}

此启动配置未运行,但它看起来像遇到断点。

它在调试器断点处打开 fs.js 并出现此错误:

错误:ENOENT:没有这样的文件或目录,访问 'node_modules/jest-cli/bin/package.json'

就像它在 jest bin 目录中寻找工作区的 package.json 文件一样。

{
    "type": "node",
    "request": "launch",
    "name": "Jest All",
    "program": "${workspaceFolder}/node_modules/.bin/jest",
    "args": ["--runInBand"],
    "console": "integratedTerminal",
    "internalConsoleOptions": "neverOpen"
}

【问题讨论】:

    标签: npm visual-studio-code jestjs gatsby


    【解决方案1】:

    对我来说,解决方案是在断点部分的 VSCodes 调试面板中,我检查了 All Exceptions。取消选中此项允许调试器按我的预期工作。

    检查Uncaught Exceptions Breakpoint 处理程序时也没有发生此问题。 All Exceptions 实际上不仅可以捕获您的代码,还可以捕获其他代码中的所有内容,无论是否已处理。

    【讨论】:

      【解决方案2】:

      我有一个 package.json 文件在一个目录上。我删除了它,但仍然得到同样的错误。我通过将其复制到路径上的新目录来修复它,我相信 VS Code 可以检测到它是一个新工作区。

      【讨论】:

        猜你喜欢
        • 2019-07-01
        • 1970-01-01
        • 2018-08-12
        • 2021-03-26
        • 2019-06-08
        • 2018-09-11
        • 2021-11-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多