Comprehensive npm Guide: Managing Packages Effectively
O
Ohidur Rahman Bappy
MAR 22, 2025
npm Versioning and Help
Get Version
npm -v
Get Help
npm help
npm
Package Initialization
Create package.json
npm init
npm init -y
Configuration Defaults
Set Defaults
npm config set init-author-name "YOUR NAME"
npm set init-license "MIT"
Get Defaults
npm config get init-author-name
npm get init-license
Remove Defaults
npm config delete init-author-name
npm delete init-license
Managing Local Packages
Installing Local Packages
npm install lodash --save
npm install moment --save
npm install gulp gulp-sass --save-dev
Installing in Different Modes
Move to Another Folder
npm install
npm install --production
Removing Modules
npm uninstall gulp-sass --save-dev
npm remove gulp --save-dev
Version-Specific Installation
Install Certain Versions
npm install lodash@4.17.3 --save
Update Packages
npm update lodash --save
Global Module Management
Install Global Module
npm install -g nodemon
npm install -g live-server
Run nodemon
nodemon
Path and Removal
Find Root Folder
npm root -g
Remove Global Packages
npm remove -g nodemon
Package Listing
Listing Packages
npm list
npm list --depth 0
npm list --depth 1
Local Module Installation
Install live-server Locally
npm install live-server --save-dev
Custom npm Scripts
"scripts": {
"start": "node index.js",
"dev": "live-server"
}