The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
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.
/template I have 2 files that
npm pack refuses to include in the final published module:
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.
By default those files are left out because they are (usually) about developing your package and not part of the package published contents. See:
You might be able to explicitly include them, but I suggest a safer and common practice is to name them differently when they are in the template folder and then rename them when you are copying as part of the generator. This makes it explicitly that they are templates and do not serve their normal purpose in the template directory itself.
Thanks I was hoping to avoid it, but thanks for confirming it’s not possible!