How to debug with vs-code and ts-node in a typescript monorepo without compile typescript

Viewed 445

I init a monorepo with lerna.

The monorepo has 2 packages: @mono/util1, @mono/util2. And util1 and util2 are linked to root node_modules as I wish:

enter image description here

util2 depends on util1

enter image description here

The 2 packages both have a src dir and a dist dir. Before I run tsc, the dist dirs are both empty.

The 2 packages both have "main": "dist/index.js" in their package.json.

Here comes the problem: when I run node -r ts-node/register packages/util2/src/index.ts with vs-code debugger, it throws an error: Error: Cannot find module '@mono/util1'

This is because in root node_modules/@mono/util1/package.json, its main filed is dist/index.js. Now I want when util2 import util1, it can resolve to node_modules/@mono/util1/src/index.tsnot to node_modules/@mono/util1/dist/index.js. What should I do?

0 Answers
Related