I replaced npm, yarn and nvm with pnpm
I used to use npm
as my package manager because I like defaults. I need to switch versions of Node.js quite often, so I used to use nvm
. When using that setup, packages globally installed via npm
are bound to the version of Node.js, so to avoid installing the same package many times for every Node.js version, I used to use yarn
for global modules. Sounds like a mess, right? I found a better way!
I replaced npm
, yarn
and nvm
with pnpm
. It stands for a “performant npm”, which is not a stretch because it is much faster than any other package manager I used. Besides that, it has many great features like workspace support, patching dependencies, managing runtime versions, peer installation and tons more! Look at the few examples of commands from my old workflow and how I mapped them to a new one.
- From
npm install
topnpm install
- From
npm install eslint
topnpm add eslint
- From
yarn global add eslint
topnpm add --global eslint
- From
nvm install lts
topnpm env add --global lts
- From
nvm use lts
topnpm env use --global lts
You might also be interested in https://github.com/antfu/ni
For now I just work on my own projects, so I don't need extra tools, but I definitely see how helpful this can be. Thanks for sharing Naser.
In the second paragraph:
I replaced npm, yarn and npm with pnpm.
I suspect the second
npm
was intended to benvm
.You are absolutely right here. Thank you for your correction and for opening the GitHub issue. You are an example of how to contribute to open source. Thank you so much, again. All corrected now.
you can try bun.Maybe this much faster than you think. I've used
pnpm
fora long time.Now I switch tobun
now. That is great. And you can try itI am aware of Bun, but I am not keen to start using something that has been released just a moment ago. I keep an eye on Bun, but I am not ready for it yet. Also, Bun is an entirely different runtime, but I need a tool that supports all my Node.js needs.
Do you think Bun now can work in windows system. In my opinions, I still unable install Bun inside my windows and try.
Looks like you can do so using WSL (Windows Subsystem for Linux). I unable to tell you how it works for two reasons. I am not a Windows user, and I I don't work with Bun.
https://bun.sh/docs/installation#windows
I also moved from npm/yarn to pnpm. the difference in speed is significant.
I tried bun. For now, it is not stable for me. I tried using Bun for my blog project and sanity plugin doesn't work with it. Maybe in a later version it gonna be more reliable :)