npm --save 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 in dev mode

npm install packageName --save-dev

Example 3: install dependencies npm

npm install

Example 4: how to install dependencies from package.json

npm install // installs dependencies listed in package.json

Example 5: npm install and add to dependancies

npm i packageName -save

Tags: