After nvm manages the node version, pnpm --version 'pnpm' is not an internal or external command, nor is it a runnable program

Problem: After the computer uses nvm to manage the version, pnpm is successfully installed and then pnpm --version is used to check whether the installation is successful, but an error is reported that
pnpm --version 'pnpm' is not an internal or external command, nor is it a runnable program. After a long time, it was finally ok. It turned out to be a problem with the npm global package path and cache path.

1. Install pnpm, check the compatibility with node first when installing , the node I use is 14, and the pnpm I installed is V7

npm install -g [email protected]

Execute pnpm --version after successful installation

pnpm --version

The result is reported as
insert image description here
a solution:
After consulting the relevant information on the Internet, you need to modify the environment variable: node_global is modified to '%NVM_SYMLINK%\node_global', the specific location is as follows, and then the
insert image description here
test still fails, and then check whether your node global path is displayed The download was successful, but there are no associated files. After investigation, it is found that the node global package path and cache path set by myself have not been modified.

insert image description here
To reset the path, you need to create new node_global and node_cache folders in nodejs in nvm and execute the following commands

npm config set prefix "D:\myNvm\nodejs\node_global"
npm config set cache "D:\myNvm\nodejs\node_cache"

insert image description here

After the execution is successful, re-execute the download command npm install -g [email protected] and then check whether the installation is successful, and the result shows that the installation is successful. insert image description here
insert image description here
Haha, it's over here. Hope to help everyone.
The following are related reference links: link 1 link 2

Guess you like

Origin blog.csdn.net/tq1711/article/details/130487478