【发布时间】:2025-11-24 22:05:03
【问题描述】:
我有一个 git root 项目,我在我的根项目中使用了一个 git 子项目。 例如,我有项目 MyApp 和一个子项目 UIComponents。 目前,我已将 UIComponents 存储库克隆到我的项目文件夹中,并将 UIComponents 添加到根项目的 .gitignore 中。 现在我想为 UIComponents 构建一个 npm 包,并且我希望能够在 npm 生产构建和开发之间切换。 问题在于开发中的导入是这样的:
import Button from './UIComponents'
使用 npm 包,导入是这样的:
import Button from '@my_name/UIComponents'
我不想每次都调整导入。 想到的第一个想法是在 node_modules 文件夹中开发 UIComponents,但这似乎不是一个好的解决方案。
【问题讨论】:
标签: javascript node.js npm yarnpkg