node.js – Debugging a NestJS app in Nx using a VScode Launch Configuration


In VSCode, I am trying to launch a NestJS application using Nx in debug mode. I am currently using the VSCode nightly js debugger extension. I am not sure what is going wrong here. I have also tried adding type “module” to the package.json file and that didn’t work either. I had to add TS_NODE_PROJECT variable as well because without it I was getting an error saying that it couldn’t find the tsconfig.json file. I am currently getting the following error:

import { __awaiter } from "tslib";

SyntaxError: Cannot use import statement outside a module
   at Module._compile (internal/modules/cjs/loader.js:891:18)
   at Module._compile 
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

here is my launch.json

"version": "0.2.0",
"configurations": [
        "type": "pwa-node",
          "request": "launch",
          "name": "Debug Nest Framework",
          "args": [
          "runtimeArgs": [
          "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}"


Here is my file structure

file structure

From most of what I have seen online, this should be working.

Source link