and*_*irl 5 node.js typescript nestjs vscode-debugger nrwl-nx
在 VSCode 中,我尝试在调试模式下使用 Nx 启动 NestJS 应用程序。我目前正在使用 VSCode nightly js 调试器扩展。我不确定这里出了什么问题。我还尝试将类型“module”添加到 package.json 文件中,但这也不起作用。我还必须添加 TS_NODE_PROJECT 变量,因为如果没有它,我会收到一条错误消息,指出找不到 tsconfig.json 文件。我目前收到以下错误:
Users/user/Documents/angular_projects/nestwktest/apps/api/src/main.ts:5
import { __awaiter } from "tslib";
^^^^^^
node_modules/source-map-support/source-map-support.js:499
SyntaxError: Cannot use import statement outside a module
at Module._compile (internal/modules/cjs/loader.js:891:18)
at Module._compile
(/Users/user/Documents/angular_projects/nestwktest/node_modules/ts-
node/src/index.ts:1056:23)
at internal/modules/cjs/loader.js:991:10
at Object..ts (/Users/user/Documents/angular_projects/nestwktest/node_modules/ts-node/src/index.ts:1059:12)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function._load (internal/modules/cjs/loader.js:723:14)
at Function.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
Process exited with code 1
Run Code Online (Sandbox Code Playgroud)
这是我的 launch.json
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node",
"request": "launch",
"name": "Debug Nest Framework",
"args": [
"${workspaceFolder}/apps/api/src/main.ts"
],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register",
"-r",
"tsconfig-paths/register"
],
"sourceMaps": true,
"cwd": "${workspaceRoot}/apps/api/",
"internalConsoleOptions": "openOnSessionStart",
"protocol": "inspector",
"env": {
"TS_NODE_PROJECT": "${workspaceFolder}/apps/api/tsconfig.json"
},
"skipFiles": ["<node_internals>/**", "node_modules/**"],
},
{
"name": "Attach to NestJS API",
"stopOnEntry": "flase",
"port": 9229,
"request": "attach",
"type": "pwa-node"
},
{
"name": "Launch Chrome against localhost",
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
Run Code Online (Sandbox Code Playgroud)
}
这是我的文件结构
从我在网上看到的大部分内容来看,这应该有效。
我面临着同样的问题。我删除了该launch.json文件。打开该auto attach --> smart功能,效果很好。如果附加调试器后代码文件中的断点仍然未绑定。尝试添加断点形式debugger -> loaded scripts --> src -> apps/abc/app.controller.ts
| 归档时间: |
|
| 查看次数: |
2518 次 |
| 最近记录: |