Skip to content

Instantly share code, notes, and snippets.

@shafiqsaaidin
Last active October 30, 2017 15:14
Show Gist options
  • Save shafiqsaaidin/d0c1e012ea75d4306fddaedfc108d2a0 to your computer and use it in GitHub Desktop.
Save shafiqsaaidin/d0c1e012ea75d4306fddaedfc108d2a0 to your computer and use it in GitHub Desktop.
Title : Npm Crash Course
Author : Musha
Date : 14/10/2017
Youtube : https://youtu.be/jHDhaSSKmB0
## Check version
npm -v / npm --version
## make the package.json
npm init / npm init -y
## set default init to custom
npm config set init-author-name "Musha"
or
npm set init-license "MIT"
## check the default init value
npm get init-author-name
npm get init-license
## delete npm custom default value
npm config delete init-author-name
npm config delete init-license
## install packages
npm install <package name> --save
*note: --save mean it will save the dependencies to package.json
npm install <package name> --save-dev
## install previous package version
npm install <package name>@x.x.x --save
npm install lodash@4.17.3 --save
## install regular package from package.json (exclude devdependencies)
npm install --production
## install package globally
npm root -g
*note: check root directory for global package
npm install -g <package name>
## remove packages
npm uninstall <package name> --save / --save-dev
npm remove -g .. #for global package
npm remove ..
npm rm / un ..
## update package
npm update <package name>
## list package
npm list
npm list --depth 0 #list only top lavel
## SCRIPT
"scripts": {
"start": "node index.js",
"dev": "live-server"
},
run the script
---------------
npm start #it will run the command node index.js
npm run dev #it will run the live-server(use run if not we not using "start")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment