Search code examples
npmyarnpkgnpx

npm, npx, and yarn. Which one is better?


I can see create-react-app has added installation with npx.

So it made me curious to check these package npm, npx and yarn.

Which one is better to use and why?


Solution

  • npm: Is used for installation of packages (libraries), i.e. pieces of functionality to help you build your own applications.

    npm website and project github repository states that

    • npm is a JavaScript package manager, just like: pip (Python), Maven (Java), NuGet (.NET), Composer (PHP), RubyGems (Ruby), ...
    • Contrary to popular belief, npm is not in fact an acronym for "Node Package Manager"
    • npm is the package manager for Node.js.
    • Help JavaScript developers easily share packaged modules of code.
    • npm is the command line client that allows developers to install and publish those packages.
    • The npm Registry is a public collection of packages of open-source code for Node.js, front-end web apps, mobile apps, robots, routers, and countless other needs of the JavaScript community.

    npx: npx is a tool to execute packages without installing the packages.


    yarn: also installation of packages. yarn is a replacement for npm that sits on top of the same packages repository.


    nvm: Node Version Manager, also there is nvm script which is used to install and management different version of node in a system.