首頁  >  問答  >  主體

您可以將路徑“...”標記為外部以將其從捆綁包中排除 - 如何?

我有一個已發佈到套件的儲存庫。我在另一個儲存庫中安裝了這個套件並想使用它,但出現錯誤:(其中 ... 是嘗試在我的套件中導入的任何套件的名稱)

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 天前383

全部回覆(1)我來回復

  • P粉011912640

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

    假設您使用 esbuild 進行打包,您應該可以使用 --external 標誌:

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

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

    回覆
    0
  • 取消回覆