Before, I installed the default nodejs package that came with Arch Linux. But sometimes I would update my operating system, and thus getting a new Node.js version, and my system would break.
With fnm, I have fine-grained control over which version of Node.js I’m running.
Now, let’s talk about package managers. Node.js ships with npm as the default package manager.
Yarn is a popular alternative to npm. Facebook developed yarn as a streamlined and safer solution to npm.
Nowadays, in 2019, npm has caught up, and both are viable choices.
But there’s a new kid on the block!
- it’s much faster
- it uses symlinks to save one version of the module instead of storing new modules in every project
- support for workspaces (for monorepos)
- it has strict, non-flat node_modules folder
The API is similar to npm. For most cases, you can just switch from npm to pnpm and everything works fine.
My advice is to install a few selected packages globally with npm/yarn. Install the rest locally with pnpm. Use Gatsby with npm/yarn.