install npm package code example

Example 1: npm install package as developer dependency

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

Example 2: install node_modules

npm install

Example 3: how to install latest version of npm package

//For global packages 
npm i -g <package name>@latest
npm i -g express@latest

//For loacal packages
npm outdated
npm update

//Manually updating local packages
npm i <package name>@latest
npm update "react" "react-dom"

Example 4: install node_modules folder

npm install (with no args, in package dir)

Example 5: how to install any package in node.js

#how to install any specific package in nodejs Application
# Syntex
npm install packagename

# example:
npm install express
npm i express

#if you install globally then type 
npm install express -g

Example 6: install npm package globally

npm install package-name -g

Tags:

C Example