首页 > 解决方案 > 使用 VSC 从我的应用程序中的 node_modules 调试库

问题描述

我工作的企业使用 react.js 开发了一个内部应用程序,typescript 也开发了一些节点模块,现在轮到我使用它了,我发现了一个让我想到这个问题的问题。

如何使用 VSC 从我的应用程序中调试节点模块?我可以访问这两个源代码。我的目录结构。

Documents
|-- my-app
    |--src
       |--App.tsx #File that import @enterprise/my-node-module and use someFunction that I want to debug
|-- my-node-module
    |--src
       |--Action.ts #File with someFunction that I want to debug
|-- another-node-module #Another node module

我还配置了 VSC 来调试我的应用程序并且运行良好。

{
  "version": "0.2.0",
  "configurations": [{
      "type": "chrome",
      "request": "attach",
      "port": 9222,
      "name": "Attach Chrome against localhost",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}"
    },
    {
      "name": "Chrome",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}/src",
      "sourceMapPathOverrides": {
        "webpack:///src/*": "${webRoot}/*"
      },
      "runtimeArgs": ["--preserve-symlinks"]
    }
  ]
}

我的应用程序中的 Package.json 脚本

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build"
  },

如您所见,我尝试使用进行调试,但没有。造成这种情况的主要原因是我不知道如何直接调试模块,并且已经构建为带有 redux-thunk 的中间件。

希望有人可以帮助我。

标签: node.jsreactjsdebuggingvisual-studio-codenode-modules

解决方案


推荐阅读