如何在不编译打字稿的情况下使用打字稿monorepo中的vs-code和ts-node进行调试

问题描述

我和lerna建立了一个monorepo。

monorepo具有2个软件包:@mono/util1@mono/util2。我希望将util1util2链接到根node_modules:

enter image description here

util2取决于util1

enter image description here

这两个软件包都有一个src目录和一个dist目录。在运行tsc之前,dist目录都为空。

这两个软件包的"main": "dist/index.js"中都包含package.json

问题来了:当我使用vs代码调试器运行node -r ts-node/register packages/util2/src/index.ts时,它会引发错误:Error: Cannot find module '@mono/util1'

这是因为在根node_modules/@mono/util1/package.json中,其主要字段是dist/index.js。现在我想在util2导入util1时,它可以解析为node_modules/@mono/util1/src/index.ts而不是node_modules/@mono/util1/dist/index.js。我该怎么办?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...