1

I tried to debug the TypeScript Express App https://github.com/schul-cloud/node-notification-service/ in Visual Studio Code.

in launch.json I added the configuration

{
        "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?

1 Answer 1

1

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:

  "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:

"runtimeArgs": ["-r", "ts-node/register", "-r", "tsconfig-paths/register"],
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.