The operation was rejected by your operating system

This problem was reported when using node.js to package vue today

npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path D:\pbs_workspace\web-vue\node_modules\.staging\echarts-2a49d5e4\dist\echarts.js.map
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\pbs_workspace\web-vue\node_modules\.staging\echarts-2a49d5e4\dist\echarts.js.map'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'D:\pbs_workspace\web-vue\node_modules\.staging\echarts-2a49d5e4\dist\echarts.js.map'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'D:\pbs_workspace\web-vue\node_modules\.staging\echarts-2a49d5e4\dist\echarts.js.map'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'D:\\pbs_workspace\\web-vue\\node_modules\\.staging\\echarts-2a49d5e4\\dist\\echarts.js.map'        
npm ERR!   },
npm ERR!   stack: "Error: EPERM: operation not permitted, unlink 'D:\\pbs_workspace\\web-vue\\node_modules\\.staging\\echarts-2a49d5e4\\dist\\echarts.js.map'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'D:\\pbs_workspace\\web-vue\\node_modules\\.staging\\echarts-2a49d5e4\\dist\\echarts.js.map',
npm ERR!   parent: 'web-vue'
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.

After consulting Baidu, solutions are provided as follows:
You need to delete the npmrc file.
Note: it is not the npmrc file under the npm module of nodejs installation directory
Instead, the. npmrc file under C:\Users {account} \

Then the question comes again, so where is the. npmrc file?
I searched in this computer for a long time and found nothing. Then I inquired about. npmrc files
To query the npmrc path, enter the following command

npm config ls -l 


Then I went to the folder again and found out whether
If it does not, the edit will be empty,

npm config edit 

Then pop up the text file. I check the directory address of the text file and find it is the same as the above
Then go to the account under the user under the c disk to query, this time there will be, then delete, and execute the clear cache command again

npm cache clean --force

And then pack

npm install

======================Method 2

Close the ide program, delete all the files in node ﹣ modules, and then npm install. If not, you can close the anti-virus software

======================Method 3
Sometimes when we pull the package-lock.json file of others on git, npm install may report an error and prompt for package breakage. Then the whole installation package under the / node_modules / file will fail due to the lack of package.

1. Clear npm agent

npm config rm proxy
npm config rm https-proxy

2. Clear npm cache

npm cache clean -f

3. Delete package-lock.json and directly

npm install

4. Delete. npmrc in the user directory
As long as you have configured parameters on the npm command line, such as

npm config set registry https://registry.npm.taobao.org

The file will be generated in the user directory

It's not easy. Finally, there will be package damage and other installation problems. In fact, I didn't expect that the easiest way is to find the damaged files and install them separately

npm install **@X.Y.Y

170 original articles published, praised 13, visited 10000+
Private letter follow

Tags: npm Vue JSON git

Posted on Mon, 10 Feb 2020 04:00:14 -0500 by dastaten