Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

grunt js installing packages

Tags:

npm

gruntjs

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?

like image 291
Jeff Storey Avatar asked Nov 19 '12 22:11

Jeff Storey


1 Answers

Yes npm install is the easiest way IMO. Getting everyone familiar with the other npm commands makes managing deps easier as well. Such as:

  • npm ls to list out the currently installed modules.
  • Or the --save flag ie, npm install grunt-html --save to install and insert the package and version into your package.json.
  • npm prune to remove modules not included in your package.json.

Other ways to manage dependencies are to commit the node_modules folder in your repository to avoid other devs from having to run npm install. Or for more complex projects consider using npm shrinkwrap to lock down dependencies to specific versions: npm shrinkwrap docs.

like image 50
Kyle Robinson Young Avatar answered Oct 16 '22 09:10

Kyle Robinson Young