Lingquan | Blog

NPM and Useful Packages

Word count: 203Reading time: 1 min
2019/01/27 Share

NPM(Node Package Manager)

1. What is NPM?

NPM could help developer to reuse other peopele’s code by fetching code from NPM registery.

2. Install NPM

Since Install Node.js will include NPM, just go to Node.js to install it. Node.js can be viewed as a tool that can make js run outside of browser.

3.How to use NPM?

  1. start using it

    npm init
  2. install packages

    npm install [-g] packagename

    Difference between global and local installation:
    Global: can use command in terminal
    Local: install packages only in current project

  3. how to use installed packages

4. Useful Packages

  1. live-server:

    Do not need refresh page anymore after you change your web page

    npm install -g live-server
  2. Lodash:

    Lodash makes JavaScript easier by taking the hassle out of working with arrays numbers, objects, strings, etc.

    npm install [--save] lodash
    # --save is not needed for node version > 5.0.0
  3. Browserify:

    Browserify lets us require(‘modules’) in the browser by bundling up all of dependencies. Browsers don’t have the require method defined, but Node.js does. With Browserify we can write code that uses require in the same way that we would use it in Node.

    npm install -g browserify
  1. 1. NPM(Node Package Manager)
    1. 1.1. 1. What is NPM?
    2. 1.2. 2. Install NPM
    3. 1.3. 3.How to use NPM?
    4. 1.4. 4. Useful Packages