So many web projects use npm to pull in their dependencies, for both the front end and back. npm install
and away it goes, pulling thousands of files into a node_modules
folder in our projects to import
/require
anything. It’s an important cog in the great machine of web development.
While I don’t believe the npm registry has ever been meaningfully challenged, the technology around it regularly faces competition. Yarn certainly took off for a while there. Yarn had lockfiles which helped us ensure our fellow developers and environments had the exact same versions of things, which was tremendously beneficial. It also did some behind-the-scenes magic that made it very fast. Since then, npm now also has lockfiles and word on the street is it’s just as fast, if not faster.
I don’t know enough to advise you one way or the other, but I do find it fascinating that there is another next generation of npm puller-downer-thingies that is coming to a simmer.
- pnpm is focused on speed and efficiency when running multiple projects: “One version of a package is saved only ever once on a disk.”
- Turbo is designed for running directly in the browser.
- Pika’s aim is that, once you’ve downloaded all the dependencies, you shouldn’t be forced to use a bundler, and should be able to use ES6 imports if you want. UNPKG is sometimes used in this way as well, in how it gives you URLs to packages directly pulled from npm, and has an experimental
?module
feature for using ES6 imports directly. - Even npm is in on it! tink is their take on this, eliminating even Node.js from the equation and being able to both
import
andrequire
dependencies without even having anode_modules
directory.
I really liked the idea on
pnpm
, but I had to drop it, because it was not linking correctly all the dependencies. For example, when I runnpmx create-react-app y-app
it does generate the node_modules very fast, because all the files were already downloaded and I liked the idea of not having the same files again on my disk, just a symlink to original package, but when I have to run the server, it says that a bunch of dependencies were missing and I was sad that I had to let it go.thanks for the share pnpm song.. i like it too..
Yarn is also working on “pnp” mode similiar to tink
I’ve been playing around with using a monorepo, using Lerna and Yarn Workspaces to manage repo dependencies at root level. “Child” apps/packages only install their own dependencies if they differ from root (this could mean different packages, or just a different version).
As part of this “journey of discovery” I found
yarn
much quicker thannpm install
, especially when setting up a CI build pipeline. Roughly 25% quicker.This is for a monorepo containing 3 Create React Apps (V2), 1 of which is a Storybook library, the other 2 are consumers of the library.