Slava Fomin II
Slava Fomin II

Reputation: 28651

What's the use of "production" flag in npm?

Some commands like npm install has a --production flag, which when used makes npm to install only dependencies listed in dependencies and not in devDependencies sections of the project manifest.

Here's the description of this flag from documentation:

With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.

However, what are the practical applications of this flag?

It can be used only when npm install is issued inside of the project directory, probably obtained by cloning a Git repository. Otherwise the package would be installed via npm install package-name and it would be automatically installed without devDependencies.

Upvotes: 7

Views: 7333

Answers (2)

AHSAN AHMAD
AHSAN AHMAD

Reputation: 21

Use in production where, you don't want to install devDependencies(use only for development).

  • npm install ---> install devDependencies + Dependencies
  • npm install --production ---> install Dependencies

Upvotes: 2

Flak
Flak

Reputation: 2670

Practical example,

on devDependencies you can have https://www.npmjs.com/package/faker which helps you to create fake data to test, which doesnt make sense in production to create fake data.

There are many other packages that you need to have only when you develop, so using flag --production make sense now :).

Upvotes: 1

Related Questions