Be the first user to complete this post
|
Add to List |
What is an npmignore file and what is it used for
You're probably aware of the .gitignore
file. But what about the less commonly talked about .npmignore
? Turns out there is a small but noteworthy difference between the gitignore and npmignore files.
The .npmignore
file is mainly used to avoid packaging files in your project that dont need to be downloaded by a client who wants to consume your package. Think of npmignore as the younger brother of gitignore. While using gitignore is the best way to avoid adding unnecessary files to your commit history and thereby your bundled package, npmignore is more permissable and lets you add files to your git repository. But it comes into play when your package is uploaded to npm, ignoring any file patterns listed when uploading the files. Another reason this is so great is because smaller package size means less download time and faster npm installs for a client!
Therefore it safe to consider it a best practice when working with nodejs or any other project that lets you upload to npm to add a .npmignore
file to smaller packages that will be reused elsewhere and use it to list the file patterns that correspond to test files, ci files, docs and examples. Basically, anything about your module that isint really needed by the consuming package is a good candiate to be mentioned in the .npmignore
file.
Also Read:
- Use node in es6 syntax with babel transpiling
- Creating a simple event emitter using nodejs
- Understanding semver versioning for your nodejs packages
- Access the request body of a post request in your nodejs - expressjs app.
- Configure The 'script' tag In package.json To Run Multiple Commands