[英]How to debug TypeScript Express app in Visual Studio Code
I tried to debug the TypeScript Express App https://github.com/schul-cloud/node-notification-service/ in Visual Studio Code. 我试图在Visual Studio Code中调试TypeScript Express应用https://github.com/schul-cloud/node-notification-service/ 。
in launch.json I added the configuration 在launch.json中,我添加了配置
{
"name": "notification service launch",
"type": "node",
"request": "launch",
"args": ["src/app.ts"],
"runtimeArgs": ["-r", "ts-node/register"],
"outFiles": [ "${workspaceRoot}/build/**/*.js", "${workspaceRoot}/node_modules/**/*.js" ],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
But when I run the configuration the debugger fails with 但是当我运行配置时,调试器将失败
Error: Cannot find module '@/routes/mail'
How do I start the debugger correctly so that it finds the modules? 如何正确启动调试器,以便找到模块?
node-notification-service
is using tsconfig-paths
to get runtime module resolution to honor the paths
defined in tsconfig.json
, as you can see in package.json
: node-notification-service
使用tsconfig-paths
来获取运行时模块解析度,以tsconfig.json
定义的paths
,如在package.json
所见:
"scripts": {
// ...
"server": "ts-node -r tsconfig-paths/register src/app.ts",
// ...
},
So you'll need to add tsconfig-paths
to your launch configuration, like this: 因此,您需要将tsconfig-paths
添加到启动配置中,如下所示:
"runtimeArgs": ["-r", "ts-node/register", "-r", "tsconfig-paths/register"],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.