首页  >  问答  >  正文

您可以将路径“...”标记为外部以将其从捆绑包中排除 - 如何?

我有一个已发布到包的存储库。我在另一个存储库中安装了这个包并想使用它,但出现错误:(其中 ... 是尝试在我的包中导入的任何包的名称)

X [ERROR] Could not resolve "@.../..."

    ../../node_modules/.../.../src/.../....ts:6:7:
      6 │ import "@.../...";
        ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  You can mark the path "@.../..." as external to exclude it from the bundle,
  which will remove this error.

X [ERROR] Could not resolve "@.../..."

    ../../node_modules/.../.../src/.../....ts:7:7:
      7 │ import "@.../...";
        ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

如何重构 url 以便可以使用该包?

P粉652495194P粉652495194207 天前385

全部回复(1)我来回复

  • P粉011912640

    P粉0119126402024-03-26 10:17:16

    假设您使用 esbuild 进行打包,您应该能够使用 --external 标志:

    esbuild entry.ts [...options...] '--external:'

    比照。 https://esbuild.github.io/api/#external

    回复
    0
  • 取消回复