Hey Friends 👋,
Not long ago, I contributed to one of Virtual Coffee's repositories. I had to install pnpm
because we no longer use yarn
. After I installed pnpm
with npm
and ran it, I got this error message:
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. 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 and opened a discussion on DEV Community that you might want to check out.
Prerequisite
- Node (version 16 and above) and npm installed on your computer.
Installation
-
Run this command in your terminal to install
pnpm
:
npm install -g pnpm
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.
-
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. 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 pathC:\Users\username\AppData\Local\pnpm
. Change theusername
to your computer's username.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.
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
Thank you for reading! Last, you can find me on Twitter, Mastodon, and BlueSky. Let's connect! 😊
Top comments (13)
I recently moved from mac (where i installed and managed everything by command line) to windows. Installing and managing all the packages was the thing that worried me the most, because it's a totally different enviroment. Then after doing some researches, i discovered Chocolatey. I think you could give it a try, it manages all the installation steps by itself. with just a command, i.e.
choco install npm
it downloads the package, install it and set the env variable. At the end of the process you're ready to go with your new package 😄I used it and installed also multiple version of PHP and it handle this perfectly!
Yeah, it's pretty evident i like it pretty much, but really if you have to install stuff on windows, give it a try 😄
I have Chocolatey. But I'm used to install things with npm, especially because most of docs are pointing to npm 😅
Well yes of course, once you enter in the whole npm enviroment you obviously install everything with the npm mackage manager, in this case npm. I use chocolatey for the step before, installing the language/enviroment. Node, python, php and so on. It's amazing for skipping the configuration part making it all ready after one command on terminal
This article save my pnpm problem 😁
Glad to hear that, Jrom! 😄
Thanks for sharing. Very useful.
Thank you. Glad to hear that it's useful for you 😀
nice newbie tutorial!
Thank you, Philip!
If pnpm is installed but the where command can't find it, it's likely that pnpm is not in your system's PATH.
pnpm, when installed globally, is usually located in the npm global installation directory. On Windows, this is typically C:\Users\YourUsername\AppData\Roaming\npm.
To verify this, you can check the npm global installation directory with the following command:
This command will return the directory where global npm packages are installed. pnpm should be in the bin subdirectory of this directory.
If pnpm is indeed there, you can add this directory to your system's PATH following the instructions provided in the previous response.
Sorry, It didn't work, actually I can't find the 'pnpm' in local folder
Have you installed the pnpm globally and search it in your program files folder?
You can also try
pnpm store path
to find it as mentioned in the Stackoverflow below.stackoverflow.com/questions/554037...
Some comments may only be visible to logged-in visitors. Sign in to view all comments.