Are there any benefits to switching to yarn?

I've noticed a trend where many new libraries advocate using yarn for installation. Is yarn better than npm in any noticable way?

Comments 3

  • It's just a trend thing in my opinion. There are some differences between the two but really nothing too important. Use whatever feels comfortable - it's only a package manager.

  • Yes, there is. The biggest difference of all is space management.
    Let me put it this way:-
    You download two plugins express and redis

    The folder structure would be( in NPM ):-
    express:
    node_modules:
    extra modules:
    node_modules: and so on
    And the same goes for Redis. The same module might have been installed 100 times already.

    In Yarn :-
    express:
    node_modules:
    only version specific ones are installed here
    Redis: same. Only version specific ones are installed in its node_modules folder.
    For everything else, it uses the main node_modules folder.

    Another big difference is caching ( something that I guess NPM lacks for now. )
    So, it works this way:
    You've downloaded 5 modules, which downloaded another 500 modules.
    Now, all those 505 modules are in your hard disk which can be installed whenever wanted.
    So, you download another 7 modules for another project. By luck, all those 500 modules are needed. So, instead of downloading them again, Yarn will simply copy it from its cache and paste it in your node_modules folder.