0

I have some node application in a monorepo setup with yarn workspaces.

The applications are using TypeScript and my start in package.json inside each application script typically just looks like this:

ts-node -r dotenv/config ./src/index.ts

Now I'd like to setup VS Code debugging of my node.js server code written in TS. I'd like to be able to run the application (like with the script above) while in VS Code debug mode at the same time.

Here's how the structure looks (simplified)

  • .vscode/launch.json (this is there the configuration needs to go I guess)
  • .yarn/... (this is where the zero-installs cache folder is located, among other things)
  • apps/my-ts-node-app/src/index.ts (the workspace I want to be able to run in VS Code debug mode, while running the server with e.g. ts-node (or open to if there's a better way).

My launch.json looks currently looks like this (but I've tried many different configurations ofc):

"configurations": [
  {
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "skipFiles": ["<node_internals>/**", "**/.yarn/**", "**/node_modules/**"],
    "program": "${workspaceRoot}/apps/my-ts-node-app/src/index.ts",
    "cwd": "${workspaceRoot}",
    "runtimeArgs": ["-r", "./.pnp.cjs", "-r", "ts-node/register"]
  }
]

When I launch it in Debug mode I get the following error:

TSError: тип Unable to compile TypeScript:
apps/my-ts-node-app/src/index.ts(1,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-express-npm-4.17.13-0e12fe9c24-12a2a0e6c4.zip/node_modules/@types/express/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(1,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-express-npm-4.17.13-0e12fe9c24-12a2a0e6c4.zip/node_modules/@types/express/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(2,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-cors-npm-2.8.12-ff52e8e514-8c45f112c7.zip/node_modules/@types/cors/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(2,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-cors-npm-2.8.12-ff52e8e514-8c45f112c7.zip/node_modules/@types/cors/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(5,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-cookie-parser-npm-1.4.3-4bda65954a-f390f3af1b.zip/node_modules/@types/cookie-parser/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(5,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-cookie-parser-npm-1.4.3-4bda65954a-f390f3af1b.zip/node_modules/@types/cookie-parser/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(20,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-url-parse-npm-1.4.8-b67d9f7c58-44a5e96ed4.zip/node_modules/@types/url-parse/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(20,8): error TS1259: Module '"C:/monorepo-test/.yarn/cache/@types-url-parse-npm-1.4.8-b67d9f7c58-44a5e96ed4.zip/node_modules/@types/url-parse/index"' can only be default-imported using the 'esModuleInterop' flag
apps/my-ts-node-app/src/index.ts(157,46): error TS2802: Type 'Uint8Array' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
...
Process exited with code 1

Any ideas or suggestions are greatly appreciated

Dac0d3r
  • 2,176
  • 6
  • 40
  • 76

0 Answers0