how to install dev dependencies npm 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: how to install as dev dependency

npm install <package-name> --save-dev

Example 3: npm install without dev dependencies

npm install --only=prod

Example 4: npm install package as developer dependency

npm install --save-dev package
# example:
npm install --save-dev nodemon

Example 5: npm install dev dependencies

npm install <package-name> --save-dev

Tags:

Misc Example