Skip to content

Instantly share code, notes, and snippets.

@brijesh-deb
Last active October 11, 2018 09:49
Show Gist options
  • Save brijesh-deb/6521fd78a9b53163696151006340f8f9 to your computer and use it in GitHub Desktop.
Save brijesh-deb/6521fd78a9b53163696151006340f8f9 to your computer and use it in GitHub Desktop.
#CheatSheet #NodeJS
  • Check nodejs version
    • Node -v
  • Running npm behind corporate proxy
  • Running js file from command prompt using node
    • Create a js file(test.js)
    • Add content: console.log('Hello')
    • Run from command prompt
      • Node test.js
    • Debugging
    • Npm commands
      • Npm start: runs the start script in package.json
      • Npm search [keyword] : search npm registry for package based on keyword
      • Npm ls : shows list of dependent packages (full list)
      • Npm ls --depth=0: shows list of dependent packages (only high level)
      • Npm ls -g --depth=0: show list of package including global ones
      • Npm docs [package]: display documentation for a particular package
      • Npm repo [package]: takes you to the repository of the package
      • Npm install [package] : install a package
      • Npm install [package] --save : install a package and save version in package.json
      • Npm install [package]@[version]: install specific version of a package
      • Npm install -g [package-name]: install package globally
      • Npm update: updates all packages
      • Npm update [package]: updates specific package
      • Npm init : create a package.json file
      • Npm help [command]: get help for a command
      • Npm uninstall [package]: to uninstall a package
      • Npm uninstall [package] --save: uninstall a package and change package.json
      • Npm outdated: show list of current, wanted and latest packages versions
      • Npm run [custom-script]: run a custom script mentioned in package.json
    • Useful packages
      • Morgan:
      • Nodemon: automatically starts node application if any file changes, useful during development.
    • Console in Chrome : f12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment