###The Problem
I recently published a package to npm and got an issue raised on Github to tell me that the build artifact hadn't been published.
The helpful person who raised the issue informed me that in the absence of an .npmignore
file, npm will use your .gitignore
file.
At the time, I had not wanted to push the build artifact to Github so I'd stuck the build
directory into my .gitignore
file. This meant that when I published the module to npm, it published everything but what I'd excluded from Github.
###The Solution
The work around for this is to create an empty .npmignore
file, this means that npm will find this file and use it instead of your .gitignore
file.
I couldn't believe that this was the correct intended functionality so I checked out the docs on npm and the documentation states exactly this.
###The Docs https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package
Use a
.npmignore
file to keep stuff out of your package. If there's no.npmignore
file, but there is a.gitignore
file, then npm will ignore the stuff matched by the.gitignore
file. If you want to include something that is excluded by your.gitignore
file, you can create an empty.npmignore
file to override it. Like git, npm looks for.npmignore
and.gitignore
files in all subdirectories of your package, not only the root directory.
###The Lesson So I really should have RTFM, but this is just something I'd totally overlooked and didn't expect. I thought I'd share my lesson just incase anyone else comes across this issue.