Solve the Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.jsprefix' error when using npm

When I set up the company mirror source, I encountered the following error: Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.jsprefix', which caused the switch to fail

 Analyze the problem: You can see that the content of the error is as follows:

 1. It can be seen that the crux of the problem is that the npm-cli.js file cannot be found.
2. Since it cannot be found, the specification means that there are some files missing under the installation directory, so let’s follow this path to see where to start 3. Open
the installation directory and find that there is no npm directory under node_modules
4. It means that we don’t know when to delete the npm directory

Solution:

1. Reinstall Node.js—more troublesome; 2. Download npm and put it in our installation directory

1. Reinstalling node.js is not an overview here, there are many tutorials on the Internet;
2. Download npm and put it in the installation directory: visit https://nodejs.org/en/download/, and download the version that matches your computer, such as Windows Binary (.zip), and then unzip the zip archive to the node_module directory, as follows:
 

Guess you like

Origin blog.csdn.net/m0_71735156/article/details/129387561