Problem with npm
- Single registry: A package should be on NpmJs.
- Queued Install: When npm gets dependencies from its repository, it install each dependency one after the other which might end up using lot of time.
- Nested Dependencies: I faced this one with my Windows machine. npm version 2 nests dependencies which leads to duplicates, and as a user of windows, file path may get longer which causes problem with windows while trying to delete them. To fix this please use npm version 3.
- No offline Installation.
Yarn will take packages from NpmJs or Bower registries. It also runs dependency installs parallel to each other. And offline installation is available for Yarn. If you have installed a package before, yarn creates a cached copy which facilitates offline installs.
In Yarn, install process is broken down into three steps:
- Resolution: Yarn starts resolving dependencies by making requests to the registry and recursively looking up each dependency.
- Fetching: Next, Yarn looks in a global cache directory to see if the package needed has already been downloaded. If it hasn’t, Yarn fetches the tarball for the package and places it in the global cache so it can work offline and won’t need to download dependencies more than once. Dependencies can also be placed in source control as tarballs for full offline installs.
- Linking: Finally, Yarn links everything together by copying all the files needed from the global cache into the local node_modules directory.
So, overall Yarn offers better workflow than npm. I have started using it and haven’t notice any problem so far. Only notice that windows user don’t get Yarn emojis when installing dependencies 😦