I’m building a grunt javascript project with grunt, and I have a package.json file that looks something like:
{
... name, author, etc here ...
"dependencies": {
"grunt-html":"0.2.1"
}
}
I can run npm install to install grunt-html and this works just fine. But when I add new dependencies, all developers on the team must know to run npm install again. Is there a way to automatically install any packages that have not yet been installed? Should I just run npm install always to ensure I’m up to date?
Yes
npm installis the easiest way IMO. Getting everyone familiar with the othernpmcommands makes managing deps easier as well. Such as:npm lsto list out the currently installed modules.--saveflag ie,npm install grunt-html --saveto install and insert the package and version into yourpackage.json.npm pruneto remove modules not included in yourpackage.json.Other ways to manage dependencies are to commit the
node_modulesfolder in your repository to avoid other devs from having to runnpm install. Or for more complex projects consider usingnpm shrinkwrapto lock down dependencies to specific versions: npm shrinkwrap docs.