Quantcast
Channel: Code Chewing » Node JS
Viewing all articles
Browse latest Browse all 6

Automatically add devDependencies on npm install

$
0
0

If you’re installing a new node module for your project, you’ll want to also add it to your devDependencies inside the package.json file. To save you having to perform this manually, you can automatically update the devDependencies when you install the node module. You simply append --save-dev to the command.

Here’s the package.json before we run the command:

{
  "name": "save-dev",
  "version": "0.0.1",
  "devDependencies": {
    "grunt": "~0.4.2"
  }
}

Let’s both install and add the node module underscore to devDependencies:

npm install underscore --save-dev

And here’s the package.json afterwards:

{
  "name": "save-dev",
  "version": "0.0.1",
  "devDependencies": {
    "grunt": "~0.4.2",
    "underscore": "~1.5.2"
  }
}

Enjoy!


Viewing all articles
Browse latest Browse all 6

Trending Articles