node.jsgruntjsnpm

What does --save-dev (or -D) mean in npm install grunt --save-dev?


I've just started using Grunt. It is pretty hard to set up and I am at the point of creating a package.json file.

Following this tutorial, it says there are 3 ways to create a package.json file.

The first is to do npm install grunt --save-dev

The first method is to navigate to the project directory via command-line(Terminal) and install grunt using npm : sudo npm install grunt –save-dev. After the install, you can use grunt-init task to automatically generate a project-specific package.json file.

But what does --save-dev (short flag -D) mean? I tried looking but it ends in vain.


Solution

  • --save-dev: Package will appear in your devDependencies.

    According to the npm install docs.

    If someone is planning on downloading and using your module in their program, then they probably don't want or need to download and build the external test or documentation framework that you use.

    In other words, when you run npm install, your project's devDependencies will be installed, but the devDependencies for any packages that your app depends on will not be installed; further, other apps having your app as a dependency need not install your devDependencies. Such modules should only be needed when developing the app (eg grunt, mocha etc).

    According to the package.json docs

    Attempt at visualising what npm install does: