# Node Package Manager Decision ###### Author(s) - Steven Cochrane ## Tech Spike Detail ## What Technical spike to evaluate Yarn as an alternative to Node Package Manager, other options were not included in the tech sopike for *reasons* ## Why Whilst NPM is usually the default choice for managing dependencies for Node projects, it can be problematic, and it's performance when retrieving dependencies can be slow. This can lead to increased wait time for developers, and for the build process. Package management has improved in years as the Node ecosystem has evolved, with Yarn emerging as a credible alternative. ## Questions * Does Yarn complicate our development process? * Can we speed up build times with Yarn? ## Outcome A decision on whether or not to proceed with Yarn as our package manager. ## Tech Spike Summary To answer the above questions, we compared NPM side by side with Yarn, evaluating speed and complexity of use. ### Node Package Manager (NPM) NPM has been the base package manager used with nodejs for many years (https://www.npmjs.com/) #### Usage npm install [package] npm install [package]@version.number.here npm uninstall [package] #### Pros * The most commonly used package manager * APVS already implemented this as part of their workflow * Guaranteed developer familiarity ### Yarn Yarn is a new package manager boasting speed, security and reliability (https://yarnpkg.com/en/) #### Usage yarn add [package] yarn add [package]@version.number.here yarn remove [package] #### Pros * Faster * Little difference from npm commands * Overlay for npm * npm still available for those who want to use it * no broken compatibility There is little to seperate the two options here, with yarn behaving in a familiar way. ### Current workspace time differences: #### NPM npm install ... npm WARN wmt-web@0.1.0 No repository field. npm WARN wmt-web@0.1.0 No license field. >>> elapsed time 1m16s ### yarn ❯ yarn [15:11:57] yarn install v0.21.3 [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 📃 Building fresh packages... ✨ Done in 21.66s. >>> elapsed time 22s Yarn is clearly faster in terms of resolving dependencies, it also boasts an offline mode which allows us to ship dependencies to a non-internet facing environment, useful for some of the elevated environments we may need to deploy to. ## Conclusion We are going with Yarn as the caching and speed boost will only increase as dependencies grow. Offline mode could be required for us in future. As it is an overlay for NPM it wont affect developer productivity or cause compatibility issues.