what does npm -D flag mean?

Solution 1:

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.

Solution 2:

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