Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm pack/publish won't pack .gitignore or .npmrc files

I have built a project generator for my company. It's a globally installed npm package, that when run, takes the entire contents of a /template directory inside the package and copies it to the user's chosen destination.

Inside /template I have 2 files that npm pack refuses to include in the final published module:

/template/.gitignore

/template/.npmrc

Everything else, including other hidden files, get packed as expected.

These 2 files are not in any root (or nested) .gitignore files, and I'm not manually specifying any files array in any package.json that npm might pick up on.

like image 727
Titan Avatar asked Oct 28 '25 00:10

Titan


1 Answers

This is intentional behaviour https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package

The workaround was to create .gitignore.template and rename on install

like image 124
Titan Avatar answered Nov 02 '25 21:11

Titan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!