How to Install pnpm with npm on Windows 11
Tags: tutorial, webdev, beginners, codenewbie
Published: 2023-07-12 17:18:20

Hey Friends 👋,

Not long ago, I contributed to one of Virtual Coffee's repositories. I had to install [`pnpm`](https://pnpm.io/) because we no longer use `yarn`. After I installed `pnpm` with `npm` and ran it, I got this error message:

```powershell
pnpm: The term 'pnpm' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
```

So I googled and searched around for answers. In one of my findings, [others got this error](https://github.com/orgs/pnpm/discussions/4732). After researching and trying things, I could install and use `pnpm` on my machine.

Depending on the `pnpm`'s version, you might encounter it or not. But I'm writing this article for those facing the same issue to make the installation process smoother.

---

**Fun Side Note:**

I wanted to know the difference between `npm`, `yarn`, and `pnpm`. So I threw [a question on Twitter](https://twitter.com/AdiatiAyu/status/1677368931994984452) and [opened a discussion on DEV Community](https://dev.to/adiatiayu/which-package-managers-4f3e) that you might want to check out.

---

## Prerequisite

- Node (version 16 and above) and npm installed on your computer.
    

## Installation

1. Run this command in your terminal to install `pnpm`:
  
    ```powershell
    npm install -g pnpm
    ```

2. Add the path for `pnpm` to the system environment in your machine.
    
  - Click the start button at the bottom bar.        
  - Search for "system environment" and click "Edit the system environment variables" — it opens the "System Properties" dialog box.        
  - In the "Advance" tab, click the "Environment Variables..." button at the bottom.
        
    ![Advance tab in the System Properties dialog box on Windows](https://cdn.hashnode.com/res/hashnode/image/upload/v1688910128828/8b13b422-bce6-45a6-9a42-7b3422e9e213.jpeg)
        
  - Double-click "Path" in the "User variables for username" on top, and check if you already have `%PNPM_HOME%`. If you don't, add it by clicking the "New" button on the right side and input it.
        
    ![User variable dialog box on Windows](https://cdn.hashnode.com/res/hashnode/image/upload/v1688910174411/7808bdb8-9fef-4911-9cdf-71493b6f52a3.jpeg)
        
  - In the "User variables for username", click the "New..." button — it opens the "New User Variable" dialog box.        
  - In the "Variable Name", type `PNPM_HOME`. And in the "Variable Value", type the path `C:\Users\username\AppData\Local\pnpm`. Change the `username` to your computer's username.
        
    ![Edit environment variable dialog box on Windows](https://cdn.hashnode.com/res/hashnode/image/upload/v1688910329914/d12805e0-e55c-408c-a06c-f699b763517f.jpeg)
        
    Do the same steps to add the variable name and value in the "System variables" at the bottom.
        

## Final Words

To write this tutorial, I uninstalled the `pnpm` dependency. I deleted all the `pnpm` paths in my machine to reproduce the problem. And I found that in the newer version of `pnpm`, we don't need to set up the path. Updating the `pnpm` version and globally installing it would fix the problem. Alternatively, you can install the `pnpm` using [a standalone script](https://pnpm.io/installation#on-windows).
However, this article will be helpful if you still want to install `pnpm` with `npm` and encounter the same problem even after updating the version or installing it globally 😊.

---

🖼️ Credit cover image: [undraw.co](https://undraw.co/)

Thank you for reading! Last, you can find me on [Twitter](https://twitter.com/@AdiatiAyu), [Mastodon](https://hachyderm.io/@AdiatiAyu), and [BlueSky](https://bsky.app/profile/adiati.ayu.bsky.social). Let's connect! 😊