How to Solve npm-install Command -4048 Error

When I reinstall the computer system, I download the front-end environment configuration again. An error occurs when configuring NPM. The main error messages are as follows:

npm WARN logfile could not create logs-dir: Error: EPERM: operation not permitted, mkdir 'E:\work\node\node_cache\_logs'
npm WARN logfile could not be created: Error: ENOENT: no such file or directory, open 'E:\work\node\node_cache\_logs\2022-08-24T09_17_13_819Z-debug-0.log'
npm WARN logfile could not create logs-dir: Error: EPERM: operation not permitted, mkdir 'E:\work\node\node_cache\_logs'
npm WARN logfile could not be created: Error: ENOENT: no such file or directory, open 'E:\work\node\node_cache\_logs\2022-08-24T09_17_14_514Z-debug-0.log'
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path E:\work\node\node_cache\_cacache
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'E:\work\node\node_cache\_cacache'
npm ERR!  [Error: EPERM: operation not permitted, mkdir 'E:\work\node\node_cache\_cacache'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'E:\\work\\node\\node_cache\\_cacache'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! Log files were not written due to an error writing to the directory: E:\work\node\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

First, check whether the parameters of system environment configuration and user environment configuration are consistent

Click the path in the system environment configuration to observe whether the path is consistent. This may be my personal reason. After reinstalling node several times, the path here is inconsistent. After the change, it is still not possible.

I thought it was caused by the command line permission problem, and found that using the administrator still does not work, and then I searched the Internet for the reason and finally found it;

  1. Find the .npmrc file under C:\Users\{account}\ and delete it
  2. After clearing npm cache:npm cache clean –force
  3. Then run the npm install command.

Read More: