最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - You can mark the path "..." as external to exclude it from the bundle - how? - Stack Overflow

programmeradmin4浏览0评论

I have a repository that I published to a package. I installed this package in another repository and want to use it but I get an error: (where the ... are the name of any package that trying to import in my package)

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 "@.../...";
        ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

How can I refactor the url so I can use that package?

I have a repository that I published to a package. I installed this package in another repository and want to use it but I get an error: (where the ... are the name of any package that trying to import in my package)

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 "@.../...";
        ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

How can I refactor the url so I can use that package?

Share Improve this question asked Apr 30, 2023 at 20:37 ESIESI 2,0571 gold badge11 silver badges24 bronze badges 1
  • 1 npm i -S <the-package> --legacy-peer-deps may also help in certain cases. – Webia1 Commented Feb 12, 2024 at 15:40
Add a ment  | 

1 Answer 1

Reset to default 6

Assuming you're using esbuild for packaging, you should be able to use the --external flag:

esbuild entry.ts [...options...] '--external:<your dependency>'

cf. https://esbuild.github.io/api/#external

发布评论

评论列表(0)

  1. 暂无评论