3 ms·
npm hell, I assume it's still a thing?
by taesu 8y ago
npm hell, I assume it's still a thing?
- Zelphyr 8y agoOh, yeah, it is. I used to love npm and then didn’t use it for several years. I’ve gone back to it lately and find myself screaming “what have you people done?!” on a regular basis now. And while we’re on the subject of package managers; do we really need so many? I know npm is terrible but it seems like everyone has decided to create their own now. I swear to god I had to use a package manager to install a package manager the other day.
- acemarke 8y agoThere's only two primary package managers for Javascript that are in common use. (For point of comparison, Java and Python are in a similar situation: Maven and Gradle, pip / pipenv / poetry / pip-tools, etc.) NPM is the package manager built by the NPM company. It's included with Node. Primary selling points: it's "official", and NPM has included the package auditing tech they purchased. Yarn was created by a team from Facebook, at a time when NPM (v2/v3) was known for being slow. Currently developed by a somewhat broader group of contributors. Primary selling points: more consistent installation behavior, "offline mirror" installations. Both tools install packages from the same servers run by the NPM company. The speeds are relatively similar these days, but that's at least partly because the competition pushed NPM to improve. And yes, Yarn is often installed via NPM, although you can install it other ways too. Both teams are working on solutions to the `node_modules` size issue. NPM is building a new package manager called "Tink" from scratch. Yarn has come up with a technique dubbed "Plug 'n Play". Both look potentially interesting. There's other package managers out there, but they're rarely used. For example, PNPM uses symlinks in each project to a global package cache, rather than installing a separate copy of a package for each project. I happen to favor Yarn myself, largely because the offline mirror feature makes it easy to have consistent, fast installs in CI builds and across platforms [0]. [0] https://blog.isquaredsoftware.com/2017/07/practical-redux-part-9-managing-dependencies/#managing-dependency-packages-for-offline-installation https://blog.isquaredsoftware.com/2017/07/practical-redux-pa...
- fineline 8y agoThere is a third alternative with a clear advantage over these two. PNPM is an NPM client that installs versioned packages into a central location and uses file system links within the 'node_modules' folder of individual projects. For a typical developer with many local projects this is a huge disk space saver. It also uses the original and much clearer nested structure of node_modules. I don't know why NPM didn't adopt the shared package approach, or why yarn didn't either, but PNPM gets it right.
- acemarke 8y agoI did list that one in my comment :)
- talkingtab 8y agoThanks for the write up! I used yarn when NPM was very slow, but I ran into some issues when I would use yarn, then later use npm or vice versa. I eventually went back to NPM and have been happy with the results. But I don't mix the two at all. So that is a question going forward - will mixing npm and yarn in the same installation result in problems and will the result be exactly the same? If not, it would be helpful to understand how the results differ.