Skip to main content

Command Palette

Search for a command to run...

--save VS --save-dev

Updated
1 min read

When installing npm packages, there are two options provided:

  • —save (-S)

  • —save-dev (-D)

So what is the diff?

npm install <package> —save

  • Is equivalent to npm install <package>, which is the default behavior.

  • It install the package under node_modules, and add the package’s version information into the package.json’s dependencies.

npm install <package> —save-dev

  • Not the default behavior, === npm install <package> -D.

  • It install the package under node_modules, and add the package’s version information into the package.json’s devDependencies.

  • These packages would not be install in prod env.

  • Suitable for packages that would only be used in dev env, like eslint, webpack, @types/react (type definition packages, provided by TS community)

Note: the reason @types/react exist only in the dev env is

  • Type definitions are only used during development to provide code hints and type checking

  • These type definitions are not needed in the production environment

  • All type information is removed in the compiled JavaScript code

--save VS --save-dev