首页 > 解决方案 > yarn publish 失败,因为 dist 文件夹被添加到 gitignore

问题描述

Yarn 想在发布节点模块时添加一个 git 标签。但是,此文件夹已添加到 gitignore。

 yarn publish dist

Output:
    The following paths are ignored by one of your .gitignore files:
    dist/package.json
    Use -f if you really want to add them.
    info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.

如何在 gitignore 中保留 dist,但要让 yarn 能够将 dist 文件夹添加到 git 提交中?

我试过了:

-.npmignore 没有 dist 文件夹(-->被纱线忽略)

- 将文件数组添加到 package.json

- 有人有其他建议吗?

标签: gitnpmyarnpkg

解决方案


我对此的解决方案(我想更多的解决方法)是yarn publish使用--no-git-tag-version选项调用,例如

yarn publish dist/ --no-git-tag-version

推荐阅读