how to install npm dev dependencies code example

Example 1: npm dev dependencies

# install as devDependency
npm install <package-name> --save-dev

# install as normal dependency
npm install <package-name> --save

# install all devDependencies listed in package.json
npm install --only=dev

# install all normal dependencies listed in package.json
npm install --only=prod
# or if NODE_ENV is set to production
npm install

Example 2: npm install without dev dependencies

npm install --only=prod

Example 3: how to update dev dependencies npm

npm update --save-dev

// Alternatively, the same command to save time
npm update -D

Example 4: npm install in dev mode

npm install packageName --save-dev

Tags:

Misc Example