npm - Error: EPERM: operation not permitted, unlink [duplicate] - node.js

This question already has answers here:
Fail to install npm package "npm ERR! errno -4048"
(21 answers)
Closed 5 years ago.
Windows 10 1703
Node 6.11.2
npm 5.4.0
Everytime I try to install an npm package (ex: npm i gulp-notify), I receive the following error:
npm ERR! path
C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json
npm ERR! code EPERM npm ERR! errno -4048 npm ERR!
syscall unlink npm ERR! Error: EPERM: operation not permitted,
unlink 'C:\Users\web-
dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! at Error (native) npm ERR! { Error: EPERM:
operation not permitted, unlink
'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! at Error (native) npm ERR! stack: 'Error:
EPERM: operation not permitted, unlink
\'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json\'\n
at Error (native)', npm ERR! errno: -4048, npm ERR!
code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR!
path:
'C:\Users\web-dev\Desktop\barber\node_modules\fsevents\node_modules\ansi-regex\package.json'
} npm ERR! npm ERR! Please try running this command again as
root/Administrator.
I ran cmd as administrator
I checked folder permissions
I cleared cache even though npm says it does it by itself
I changed npm prefix to C:\Users\User Name\AppData\Roaming\npm
Nothing helps.
Please advise.

Apparently I was trying to install packages locally instead of globally without the -g flag. Sorry about that. All is working now.

Related

npm ERR! Error: EPERM: operation not permitted, unlink Windows [duplicate]

This question already has answers here:
npm install give Error: EPERM, unlink
(8 answers)
Closed 3 years ago.
I can't get npm install to work in an angular project. The install almost goes through but fails with
npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'
npm ERR! [OperationalError: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'] {
npm ERR! cause: [Error: EPERM: operation not permitted, unlink 'C:\workspaces\my-project\my-module\node_modules\.staging\typescript-d1902bf5\lib\typescriptServices.js'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js'
npm ERR! },
npm ERR! stack: "Error: EPERM: operation not permitted, unlink 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\workspaces\\my-project\my-module\\node_modules\\.staging\\typescript-d1902bf5\\lib\\typescriptServices.js',
npm ERR! parent: 'my-module'
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.
What I've tried:
Running from cmd, git bash and power shell both as a regular user and as admin
Deleting the node_modules folder and retrying
installing nvm for Windows and installing nodejs 12.13.0 LTS (which then installs npm), then trying npm install
uninstalling nvm for Windows and installing nodejs 12.13.0 LTS with the site's installer, npm i -g npm, npm install
excluding my workspaces dir in Windows security settings
npm cache verify, npm install
npm cache clean --force, npm install
Can anyone suggest something I may not have thought of? Unfortunately I can't post my package.json or .npmrc as the repository I'm using is not public but from the looks of the error it should be irrelevant.
Update
It looks like it might be a race condition. See here. I'm using npm version 6.13.0.
Another update
I've got other problems now but Jonathan Irvin's comment helped me, in particular this. I disabled windows indexing and gave all permissions to my user.
try npm unlink on the root directory of the project.

Error while creating new project in angular

I am trying to create new angular project using the command ng new my-app. And the installed versions are listed below
Angular CLI : 6.0
Node version : 10.5.0
Npm : 6.1.0
I am getting the following error message,
ERR! path D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts'
npm ERR! { [Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\ng\newapp\node_modules\.staging\typescript-4c0ca0e6\lib\lib.dom.d.ts'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts' },
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, unlink \'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'D:\\ng\\newapp\\node_modules\\.staging\\typescript-4c0ca0e6\\lib\\lib.dom.d.ts',
npm ERR! parent: '#angular-devkit/build-optimizer' }
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 (though this is not recommended).
temporary fix, downgrade npm to 5.3
npm install npm#5.3 -g
Use administrator privileges. Error says you are not using admin CMD
Install packages after closing your code editor,
Are you using Node Cmd or any IDE(like VSCode) to create new project
try this command
npm i -g #angular/cli
ng new app-name
cd app-name.
ng serve

Error: EPERM: operation not permitted, unlink 'C:\wamp64\www\dev\node_modules\.staging'

Any one can help me with this npm error
npm version: 5.5.1,
node version: 8.9.1,
os: windows 10 64-bit
S C:\wamp64\www\dev> npm install bulma
npm ERR! path C:\wamp64\www\dev\node_modules\.staging
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink
'C:\wamp64\www\dev\node_modules\.staging'npm ERR! { Error: EPERM: operation
not permitted, unlink 'C:\wamp64\www\dev\node_modules\.staging'
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink
\'C:\\wamp64\\www\\dev\\node_modules\\.staging\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\wamp64\\www\\dev\\node_modules\\.staging' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Akshay\AppData\Roaming\npm-cache\_logs\2017-12-
10T10_34_23_659Z-debug.log
Error: EPERM: operation not permitted, unlink
'C:\wamp64\www\dev\node_modules.staging'
This is a known issue and lots of npm users have the same problem. My experience is to downgrade my local npm version to 5.0.3 and it worked. For more details, please see this github post: https://github.com/npm/npm/issues/18380

Cannot install Webpack with NPM

npm install --save-dev webpack gives me the following error:
$ npm install --save-dev webpack
> uglifyjs-webpack-plugin#0.4.6 postinstall C:\Users\Martin\Desktop\JS\React\Mi-config\node_modules\uglifyjs-webpack-plugin
> node lib/post_install.js
npm ERR! path C:\Users\Martin\Desktop\JS\React\Mi-config\node_modules\fsevents\node_modules\ansi-regex\package.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\Martin\Desktop\JS\React\Mi-config\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! at Error (native)
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Users\Martin\Desktop\JS\React\Mi-config\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! at Error (native)
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink \'C:\\Users\\Martin\\Desktop\\JS\\React\\Mi-config\\node_modules\\fsevents\\node_modules\\ansi-regex\
\package.json\'\n at Error (native)',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\\Users\\Martin\\Desktop\\JS\\React\\Mi-config\\node_modules\\fsevents\\node_modules\\ansi-regex\\package.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Martin\AppData\Roaming\npm-cache\_logs\2017-09-11T13_53_27_111Z-debug.log
It doesn't get added to package.json either
Can anyone help me please? I've reinstalled latest stable node version but still doesn't work.
Consider trying npm install --no-optional webpack --save-dev.
At least with Node 8.4 + npm 5.4.0 this helped me work around this today.
Close IDE and then try. It works for me

Can't install package with npm install, EPERM error

I got an error when I try to install any package with npm install.
Here is an example when I try to install chart.js
H:\testNG>npm install chart.js --save npm ERR! path
H:\testNG\node_modules\fsevents\node_modules\aws-sign2\package.json
npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink npm
ERR! Error: EPERM: operation not permitted, unlink
'H:\testNG\node_modules\fsevents\node_modules\aws-sign2\package.json'
npm ERR! at Error (native) npm ERR! { Error: EPERM: operation not
permitted, unlink
'H:\testNG\node_modules\fsevents\node_modules\aws-sign2\package.json'
npm ERR! at Error (native) npm ERR! stack: 'Error: EPERM:
operation not permitted, unlink
\'H:\testNG\node_modules\fsevents\node_modules\aws-sign2\package.json\'\n
at Error (native)', npm ERR! errno: -4048, npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink', npm ERR! path:
'H:\testNG\node_modules\fsevents\node_modules\aws-sign2\package.json'
} npm ERR! npm ERR! Please try running this command again as
root/Administrator.
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\flaur\AppData\Roaming\npm-cache_logs\2017-09-04T16_16_04_331Z-debug.log
I will provide the log file if someone want to watch it
https://1drv.ms/u/s!AgNenwMMyZRWg4tRDcK4OeoiZKeVZw
i was occur same thing. now, i solved. that's so simply
npm 4.0 was not apply.. some node_modules packages.
so you re install npm3.0

Resources