24 May 2016

Node Package Manager

Node.js (https://nodejs.org/en/)
Node Package Manager (https://docs.npmjs.com) is used to install other dependencies (e.g. bower) and process upgrades.
Note npm is server side focused so may install multiple versions of the same package for reliability, whilst Bower is client-side focused so produces a flat dependency tree.
  • Pre-requisit: 
  • Install Node.js (also npm): 
    • Windows: choco install nodejs.install
    • Mac OSX (Homebrew): brew install node
    • Ubuntu: sudo apt-get update && sudo apt-get install nodejs && sudo apt-get install npm
  • Manifest (pacakge.json): npm init --yes
  • Update: npm upgrade | npm update | npm update -g
  • Packages:
    • Search: npm search <package_name>
    • Install: npm install <package_name> --save
      NB: the --save option adds them to the package.json file
    • List installed: npm list
    • Update installed: npm update 
    • Unistall: npm uninstall <package_name> --save
    • Cleanup: npm prune
    • Initialize: npm init
    • Manifest: package.json
    • Restore packages: delete node_modules then run: npm install

No comments:

Post a Comment