NPM report error: eperm: operation not permitted, unlink… Solution and clear cache_ modules

Due to domestic and foreign environmental factors, NPM install often has various problems, especially “error: eperm: operation not permitted, unlink…” This is a mistake.

This error is misleading because of the error information, which leads to a lot of solutions proposed on the Internet, such as setting permissions and entering as an administrator.
In fact, the reason for this error is that the network is unstable, resulting in incomplete or error downloading of NPM package. What, your home’s 100m optical fiber network is flying fast?But the server is foreign, so it should be slow when it is slow.
After an error, most people will NPM install again, and the NPM install command will not take the initiative to clear the last installed package. However, the package you installed last time is incomplete, and there is a dependency relationship between packages. As a result, errors will naturally occur.

Therefore, in order to solve this problem, you should clear the last installed package. If you want to clear it completely, you generally need the following two steps:

Delete all files in node modules. Clear the NPM cache.

There are two ways to delete the node modules file:
1. Right click to delete it directly. The disadvantage is that the deletion speed is very slow when there are too many dependencies.
2. Install rimraf to delete [wall crack recommended, speed of light].

Install (Global install recommended)

npm install -g rimraf

first in node_ The folder where the modules are located. And then directly input:

rimraf node_ modules

There are two ways to clear the NPM cache:
the first one is to delete the cache file directly, and delete the file of C: (users \ \ user name. Npmrc).
The second is to execute: NPM cache clean — force, which also achieves the purpose of clearing cache files.

Read More: