Solve the problem of Error: Cannot find module 'C:\Users\xxx\AppData\Roaming\npm\...\pnpm.cjs

background

  1. Install Nodejs to the C drive, and the environment variable configuration is the default.
  2. Install pnpm and you can use it normally in the future. . .
  3. For some reason, I wanted to uninstall Nodejs and reinstall it. In the process, I deleted this directory C:\Users\xxx\AppData\Roaming\npm\ (the default installation directory for npm download dependencies)
  4. After reinstallation, the environment variables are also configured to the D drive and so on.
  5. When installing pnpm, it is also installed in the Nodejs directory on drive D. When you enter the command pnpm -v to view the version, an error occurs. . .

Error screenshot

Insert image description here

solve

Just delete the files in the user directory as shown in the picture
Insert image description here

Reason (possible)

Maybe I didn't uninstall Nodejs cleanly. . . There are residues.
When you enter pnpm -v on the console to check the version number, it defaults to looking for pnpm in the user directory on the C drive, but it cannot be found. . .
Because I reinstalled Nodejs, the environment variables are also configured in the Nodejs directory of the D drive. When downloading pnpm, it will be installed in the Nodejs directory of the D drive, so I get an error saying pnpm cannot be found.

Guess you like

Origin blog.csdn.net/DaXiongRen/article/details/128996325