npm stands for Node Package Manager for the JavaScript programming language. It is released 2010 with support for Node. npm is installed with Node automatically. It is generates ‘package-lock.json’ file.

Yarn stands for Yet Another Resource Negotiator, And it is popular package manager. It is released by Facebook in 2016. It is generates ‘yarn.lock’ file.


  • Install dependencies:

    npm : npm install
    yarn : yarn


  • Install a package and add to package.json:

    npm : npm install package --save
    yarn : yarn add package


  • Install dev package:

    npm : npm install package --save-dev
    yarn : yarn add package --dev


  • Uninstall package from package.json:

    npm : npm uninstall package --save
    yarn : yarn remove package


  • Remove a dev dependency from package.json:

    npm : npm uninstall package --save-dev
    yarn : yarn remove package


  • Upgrade a package to its latest version:

    npm : npm update --save
    yarn : yarn upgrade


  • Install a package globally:

    npm : npm install package -g
    yarn : yarn global add package


  • Uninstall a package globally:

    npm : npm uninstall package -g
    yarn : yarn global remove package