Be the first user to complete this post

  • 0
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:

  1. Debugging nodejs applications using node-inspector and Chrome Dev Tools
  2. Send email using nodejs and express in 5 simple steps
  3. Configuring jshint as a pre-commit hook for your nodejs applications
  4. Configure The 'script' tag In package.json To Run Multiple Commands
  5. exports is not defined