287

I am about to install this npm package and it says npm install -D load-grunt-config. What does the -D flag do?

5

2 Answers 2

338

The -D flag is the shortcut for: --save-dev. Source: https://docs.npmjs.com/cli/install

-D, --save-dev: Package will appear in your devDependencies.

5
  • 62
    So, what does it do?
    – Kevin
    Commented Feb 2, 2016 at 14:22
  • @kevin: stackoverflow.com/questions/19223051/…
    – spb
    Commented Mar 18, 2016 at 18:48
  • 3
    For me, the -D flag will not update package.json, forcing me to use --save-dev instead. Crazy as usual :( Commented Oct 27, 2017 at 14:44
  • 1
    @Kevin That's another topic isn't it?
    – Hiro
    Commented Nov 18, 2019 at 4:44
  • 5
    @Hiro, OP wrote "what does the -D flag do?" Commented Aug 25, 2020 at 1:26
42

As described in the NPM Install Docs:

-D, --save-dev: Package will appear in your devDependencies.

Which means that the package will not be installed if you do npm install --production.

A detailed explanation of the different types of dependencies: SO-Answer

1
  • 2
    Adding to this, the equivalent using yarn is yarn add <package...> [--dev/-D] Commented Aug 22, 2019 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.