An example of how to use NPM in your project. All dependencies aren't included in the repository because of the .gitignore file.
This project requires Node.js v4+ to run.
Install the dependencies from the package.json file to successfully run the project
$ cd NPM-example
$ npm install
To install npm in your project you first need to have a valid version of nodejs on your computer/server.
$ cd project_name
$ npm init
Follow the prompts it gives you. It will then create a package.json file for you in your project. The package.json file includes all the dependencies needed for your project to run. Because you are using NPM, these dependencies don't need to be sent up to git. So make sure to ignore the node_modules folder in your .gitignore.
Find the package you want to include from the NPM site. When you have found the package you want type in
$ npm install package_name --save
This adds the package onto your package.json file and also adds all the required folders in the node_modules folder.
If a new version of a package comes out, all you need to say is
$ npm update
This reads your entire package.json file and searchers for the latest versions for all the dependencies which have the caret symbol (^) before the version number. The caret stands for the latest version higher than the version number given.
You don't want to manually remove the packages from the node_modules folder. And often one dependency includes multiple folders. To remove any package you just call
$ npm remove package_name --save
This removes the dependency from the package.json file as well as the node_modules folder. It won't remove any instances of it throughout the project though.