What exactly should I put in .npmignore
?
Tests? Stuff like .travis.yml
, .jshintrc
? Anything that isn't needed when running the module (except the readme)?
I can't find any guidance on this.
npmrc with a command-line flag. Using --userconfig=/dev/null should bypass the userconfig (on Linux and other UNIX-like operating systems). For situations where you need to bypass only the registry setting, you can use the --reg or --registry command line flags, or set an npm_config_registry environment variable.
. npmignore is a file used to ignore files while publishing your node package to npm registry. By using a . npmignore file in your node package root you can keep stuff out of your package.
Run npm version on Project A using semantic versioningRun npm publish Go to npmjs.org to check the new version is been publishedUpdate the package. json file in Project BRun npm install in Project B to pull the new version of Project ARun all tests againGood to go!
Publishes a package to the registry so that it can be installed by name. By default npm will publish to the public registry. This can be overridden by specifying a different default registry or using a scope in the name, combined with a scope-configured registry (see package. json ).
As you probably found, NPM doesn't really state specifically what should go in there, rather they have a list of ignored-by-default files. Many people don't even use it as everything in your .gitignore
is ignored in npm
by default if .npmignore
doesn't exist. Additionally, many files are already ignored by default regardless of settings and some files are always excluded from being ignored, as outlined in the link above.
There is not much official on what always should be there because it is basically a subset of .gitignore
, but from what I gather from using node for 5-ish years, here's what I've come up with.
Note: By production I mean any time where your module is used by someone and not to develop on the module itself.
.coffee
files in your package but keep tracking them in your git repository.node-gyp
might have object files that get generated during a build that never should go into the package..gitignore
anyway. You must place these things inside here if you are using a .npmignore
file already as it overrides .gitignore
from npm's point of view..travis.yml
are not required for using, testing, or viewing the code.CNAME
files or placeholder index.html
s if you use your module serves double-duty as a gh-pages
repository as well.npm install
, I should only be relying on npm and no other external sources.Basically, you should ever use it if there is something you wish to keep out of your npm package but not out of your npm repository. It's not a long list of items, but npm would rather build in the functionality than having people stuck with irrelevant objects in their package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With