Skip to content

Instantly share code, notes, and snippets.

@cynthiateeters
Forked from bradtraversy/npmcrashcourse.txt
Last active August 31, 2021 22:07
Show Gist options
  • Select an option

  • Save cynthiateeters/80040fcd559fc84c93b56ef2eef68f15 to your computer and use it in GitHub Desktop.

Select an option

Save cynthiateeters/80040fcd559fc84c93b56ef2eef68f15 to your computer and use it in GitHub Desktop.
NPM Crash Course Commands
# GET VERSION
npm -v (or --version)
# GET HELP
npm help
npm
# CREATE PACKAGE.JSON
npm init
npm init -y (or --yes)
# 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
# INSTALLING LOCAL PACKAGES FOR PRODUCTION
npm install date-fns (or npm i --save date-fns)
# INSTALLING LOCAL PACKAGES FOR DEVELOPMENT
npm install nodemon -D (npm install nodemon --save-dev)
# INSTALLING GLOBAL PACKAGES (making them available in anytime with npm)
npm install nodemon -g (to install this tool globally)
# INSTALL EVERYTHING (useful with newly cloned repos having a package.json file)
npm install
# INSTALL FOR PRODUCTION (no devDependencies)
npm install --production
# REMOVING MODULES
npm uninstall gulp-sass --save-dev
npm remove gulp --save-dev
#INSTALL CERTAIN VERSIONS
npm install lodash@4.17.3 --save
# UPDATE
npm update lodash --save
# INSTALL GLOBAL MODULE
npm install -g nodemon
npm install -g live-server
# RUN NODEMON
nodemon
# FIND ROOT FOLDER
npm root -g
# REMOVE GLOBAL PACKAGES
npm remove -g nodemon
# LISTING PACKAGES
npm list
npm list --depth 0
npm list --depth 1
# INSTALL LIVE-SERVER LOCALLY
npm install live-server --save-dev
# NPM SCRIPT
"scripts": {
"start": "node index.js",
"dev": "live-server"
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment