Skip to content
Theme:

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 to pnpm install
  • From npm install eslint to pnpm add eslint
  • From yarn global add eslint to pnpm add --global eslint
  • From nvm install lts to pnpm env add --global lts
  • From nvm use lts to pnpm env use --global lts

Thank Zoltan for pnpm!

Comments

  • t
    thenbe

    You might also be interested in https://github.com/antfu/ni

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • Paweł Grzybek
      Paweł Grzybek

      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.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
  • J
    Jim T

    In the second paragraph: I replaced npm, yarn and npm with pnpm.

    I suspect the second npm was intended to be nvm.

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • Paweł Grzybek
      Paweł Grzybek

      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 use Markdown here

      Your comment is awaiting moderation. Thanks!
  • M
    MIchael Ho

    you can try bun.Maybe this much faster than you think. I've used pnpm fora long time.Now I switch to bun now. That is great. And you can try it

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!
    • Paweł Grzybek
      Paweł Grzybek

      I 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.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
    • S
      Sunwoo Jun

      Do you think Bun now can work in windows system. In my opinions, I still unable install Bun inside my windows and try.

      👆 you can use Markdown here

      Your comment is awaiting moderation. Thanks!
      • Paweł Grzybek
        Paweł Grzybek

        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

        👆 you can use Markdown here

        Your comment is awaiting moderation. Thanks!
  • M
    Maciej

    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 :)

    👆 you can use Markdown here

    Your comment is awaiting moderation. Thanks!

Leave a comment

👆 you can use Markdown here

Your comment is awaiting moderation. Thanks!