Npm vs Yarn

Both npm and Yarn are two well-known JavaScript package managers.  It  automates the process of installing, updating, configuring, and removing  packages retrieved from a global registry.

What is npm?

NPM basically is the package manager for node. It helps with installing various packages and resolving their various dependencies. It greatly helps with your Node development. NPM helps you install the various modules you need for your web development.The main goal, as you touched upon, is automated dependency and package management. This means that you can specify all of your project’s dependencies inside your package.json file, then any time you (or anyone else) needs to get started with your project they can just run npm installand immediately have all of the dependencies installed. On top of this, it is also possible to specify what versions your project depends upon to prevent updates from breaking your project.

What is Yarn?

Yarn is a JavaScript Package Manager, a direct competitor of npm, and it’s one of Facebook most popular Open Source projects.

It’s compatible with npm packages, so it has the great advantage of being a drop-in replacement for npm.

The reason you might want to use Yarn over npm are:

  • faster download of packages, which are installed in parallel
  • support for multiple registries
  • offline installation support
Comparing Yarn vs npm

Yarn has a few characteristics that set it apart from npm (especially version of npm previous to 5.0). A few of these include the following.

1.The yarn.lock File

Managing version numbers in package.json can get messy sometimes. However, the yarn.lock file helps alleviate the mess. Whenever you add a new module, Yarn updates a yarn.lock file. Similar to the Gemfile.lock feature in Ruby, the yarn.lock file ensures that the exact same package gets installed on every device. These lockfiles are called as such because they “lock” dependencies to their specific versions during installation. A lockfile consists of ordered keys to ensure minimal changes to the file structure in node_modules across all machines.

2.Package Installation

When installing a package, npm performs the necessary steps sequentially, meaning that each package must be fully installed before moving to the next. However, Yarn has the power to perform multiple installation steps at once, which drastically speeds up the process.

This is similar to the parallelism seen in HTTP/2.


Yarn was always much faster than any of the npm versions below 5.0. The team at npm announced that npm 5.0 would be 5x faster than its predecessor for certain operations. However, as shown by the results below from Scott Logic, Yarn still appears to be faster than npm 4 and 5 when testing with some fairly simple dependencies.

Furthermore, npm 5 doesn’t seem to provide much greater speeds than it’s predecessor. This may not mean much when you’re installing something like the gulp package, but it can make a huge difference in larger projects. Thanks to Yarn, bigger builds no longer necessarily entail longer build times.


A major problem with npm is that it automatically runs code from dependencies and permits packages to be added on the fly, While this feature comes with its conveniences, it also creates security vulnerabilities. Since Yarn only installs from your yarn.lock or package.json files, it’s considered to be more secure, which is increasingly important in today’s world. Yarn also makes use of checksums before installation to ensure the integrity of each package

Yarn vs Npm: Syntax
Yarn NPM
yarn: This command is used to install all the packages in a package.json file. npm install: This is used by NPM to install packages from the package.json file.
yarn run: This command is used to run script object specified in the package.json file. npm runnpm run is an alias for the command npm run-script, which does the same thing thing as its Yarn equivalent.
yarn add [package]: This command is used to install a package npm install [package]: This installs a package from NPM.
yarn remove [package]: This command is used to remove a package. npm uninstall [package]: This is the NPM equivalent for removing or uninstalling packages.
yarn version: This command is used to update the version of your application using semantic versioning. npm version: This command lists the version of your application, Node, NPM as well as other Node dependencies.
yarn upgrade: This command upgrade all the packages in the package.json file. NPM has an equivalent but is an installed package. [npm-upgrade](


Add a project to a new repository on Bitbucket

If you have code on your local machine that is not under source control, you can prepare it by putting your code into a Git repository locally.

  1. From your terminal, change to the root directory of your existing code.
  2. Initialize the directory under source control from the following command:
  3. Add the existing files to the repository you have initialized:
  4. Commit the files:

    On macOS, you can use single quotes or double quotes around the comment message. On Windows, you must use double quotes.

  5. Connect your new local Git repository to the remote repository on Bitbucket. To do so, enter git remote add origin with the remote URL:

    You can find the URL next to the git clone command for the repository:

  6. Push all the code in your local repo to Bitbucket with the following command:


React installation on Ubuntu 16.04

1.Install Git to get code from the various repository.

2. Take the pull from bitbucket and give the parent file in which express and react are downloaded, following commands:

Here user name is your system user name.

Here taking the git pull means cloning from bitbucket.For this you  need to go to express and react repositories on bitbucket and click on the clone button on topmost right side. It will give you link like this

Just copy this where ever you wanted to set up your project. Normally we do this here :

2. Node

First install curl

Node JS

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications.


Npm is a package manager. Typically this software is installed to build Node applications.It let’s you install software (libraries, plugins, frameworks and applications).

This will install node and npm both.

To check the installed version :

3. Install node version manager

Note: On Linux, after running the install script, if you get nvm: command not found or see no feedback from your terminal after you type:

Close the terminal and open it again.

If you want to see what versions are installed:

To install a particular node version :

4. Mongo(This works like charm as official mongodb website key is not working)

Install mongo :

For starting mongod services :

To know current status :

5. Install yarn

6. Final step

Now just go to your express and react folders from command prompt and run


Story of yarn.lock

Should you be committing yarn.lock file?

Ans: Yes

In order to understand Yes, let’s dig down a bit on story of yarn.lock file

How Yarn maintains package consistency across machines?

It’s done in 2 ways

    1. Yarn created entire dependency tree using a deterministic algorithm before downloading packages from everchanging third party packages
    2. All the info related to dependency tree is maintained in yarn.lock file so that it can be shared between every system installing the dependencies.

… To be continued

S3 Bucket Copy from one bucket to another

We can copy content of one bucket to another by following:

1. AWS Console
– Login to AWS Console
– Go to
– Enter into source bucket
– select directory to be copied
– select “Copy” from “More” option
– select destination bucket
– select “Paste” option from “More” to destination directory. (Paste option can take some time to activate.)
Setup AWS Cli
sudo apt-get install awscli
aws configure
– Enter AccessKey
– Enter SecretKey
– Enter Out Format

Command to copy files:

s3 sync s3://sourcebucket/directory/ s3://destinationbucket/directory --exclude *.tmp

PPH Coding convention

Are you the person who has moved from JAVA to PHP and you are confused about PHP coding convention? Then this is place for you.

Following are the cases in which you define everything
1. PascalCase = ThisIsMyClass
2. camelCase = thisIsMyClass
3. lower_case = this_is_my_variable

NOTE: Difference between Pascal case and camelCase is first character of the word.

Drupal with composer – What to do and what not to do

Composer Manager allows custom/contributed modules to depend on PHP libraries managed via Composer.

Composer is a command line tool for installing PHP libraries and their dependencies on a per-project basis. These day, all libraries are registered on Packagist(You can define package dependencies here) and expect to be installed via Composer.

Use module to start using composer in your drupal 7 project.