Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yarn publish fails because dist folder is added to gitignore

Tags:

git

npm

yarnpkg

Yarn would like to add a git tag when publishing a node module. However this folder is added to 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.

How can you keep dist in gitignore, but make an exception for yarn to be able to add the dist folder to a git commit?

I've tried:

-.npmignore without dist folder (-->ignored by yarn)

-add a files array to package.json

-anyone has other suggestions?

like image 260
Vincent Avatar asked Oct 22 '25 17:10

Vincent


1 Answers

My solution to this (more of a work-around, I suppose), is to call yarn publish with the --no-git-tag-version option, e.g.

yarn publish dist/ --no-git-tag-version
like image 125
simon Avatar answered Oct 25 '25 07:10

simon