Angular-cli: EPERM: operation not permitted, unlink

Created on 13 Sep 2017  路  20Comments  路  Source: angular/angular-cli

I am getting the similar error when I tried to install with Angular 4.2.4 [ npm i ag-grid --save ]. My node version is 8.4.0 and npm version is 5.4.1. The installation is conflicting something with "fsevents"...I even tried to use the command "npm cache clean --force"...Here is the error,

npm ERR! path I:\git\AngularAppSamplenode_modules
fseventsnode_modules\abbrevpackage.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'I:\git\AngularAppSamplenode_modules\fseventsnode_modules\abbrev\package.j
son'
npm ERR! { Error: EPERM: operation not permitted, unlink 'I:\git\AngularAppSamplenode_modules\fseventsnode_modules\abbrev\packag
e.json'
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink 'I:\git\AngularAppSamplenode_modules\fsevents\node_modul
es\abbrevpackage.json'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'I:\git\AngularAppSample\nod
e_modules\fseventsnode_modules\abbrevpackage.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\sath\AppData\Roaming\npm-cache_logs\2017-09-12T21_37_0
9_061Z-debug.log

Most helpful comment

@jishnudev Try to close your IDE and execute again from console.

All 20 comments

I'm having the same issue. Latest NPM / Nodejs / Yarn

It's a known NPM 5.4 issue. Downgrade to 5.3.
https://github.com/npm/npm/issues/18380

Hello, This issue is fixed once I cleaned up the node_modules folder completely and re-import all the packages again. I am using NPM 5.4.1. Thank you for your suggestion.

Same error

npm ERR! path C:\Users\Jishnu\Desktop\my-appnode_modules\fseventsnode_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'C:\Users\Jishnu\Desktop\my-appnode_modules\fseventsnode_modules'
npm ERR! { Error: EPERM: operation not permitted, scandir 'C:\Users\Jishnu\Desktop\my-appnode_modules\fseventsnode_modules'
npm ERR! stack: 'Error: EPERM: operation not permitted, scandir \'C:\Users\Jishnu\Desktop\my-app\node_modules\fsevents\node_modules\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'scandir',
npm ERR! path: 'C:\Users\Jishnu\Desktop\my-app\node_modules\fsevents\node_modules' }
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\Jishnu\AppData\Roaming\npm-cache_logs\2017-10-19T02_38_07_564Z-debug.log

Package install failed, see above.
Package install failed, see above.

@jishnudev Try to close your IDE and execute again from console.

@andrexx thanks for your help, in my case I closed all prompt IDE etc and run again its work

Thanks @ssashok10 . It's Resolve after deleting node_modules folder and install all node packages again.

try deleting the node_modules and install the dependencies again...!

close IDE, and reinstall worked for me.

  1. Run command prompt as Administrator.
  2. Ran npm clean cache.
    After run this command and return Error than run .
    ( npm cache clean --force )
  3. npm install -g angular-cli

I am getting the similar error when I tried to install with Angular 6.0. My node version isv8.11.3 and npm version is6.1.0. The installation is conflicting something with "fsevents"...I even tried to use the command "npm cache clean --force"...Here is the error,

26322 warn @swimlane/[email protected] requires a peer of @types/dragula@^2.1.33 but none is installed. You must install peer dependencies yourself.
26323 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\node-sass):
26324 warn enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: Cannot cd into 'H:\angular-material-app-masternode_modules.staging\node-sass-849c4ff0'
26325 verbose enoent SKIPPING OPTIONAL DEPENDENCY: This is related to npm not being able to find a file.
26325 verbose enoent SKIPPING OPTIONAL DEPENDENCY:
26326 verbose stack Error: EPERM: operation not permitted, unlink 'H:\angular-material-app-masternode_modules.staging@angular\compiler-f002f831\bundles\compiler.umd.min.js.map'
26327 verbose cwd H:\angular-material-app-master
26328 verbose Windows_NT 10.0.17134
26329 verbose argv "F:\node\install\node.exe" "C:\Users\peng\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install"
26330 verbose node v8.11.3
26331 verbose npm v6.1.0
26332 error path H:\angular-material-app-masternode_modules.staging@angular\compiler-f002f831\bundles\compiler.umd.min.js.map
26333 error code EPERM
26334 error errno -4048
26335 error syscall unlink
26336 error Error: EPERM: operation not permitted, unlink 'H:\angular-material-app-masternode_modules.staging@angular\compiler-f002f831\bundles\compiler.umd.min.js.map'
26336 error { Error: EPERM: operation not permitted, unlink 'H:\angular-material-app-masternode_modules.staging@angular\compiler-f002f831\bundles\compiler.umd.min.js.map'
26336 error cause:
26336 error { Error: EPERM: operation not permitted, unlink 'H:\angular-material-app-masternode_modules.staging@angular\compiler-f002f831\bundles\compiler.umd.min.js.map'
26336 error errno: -4048,
26336 error code: 'EPERM',
26336 error syscall: 'unlink',
26336 error path: 'H:\angular-material-app-master\node_modules\.staging\@angular\compiler-f002f831\bundles\compiler.umd.min.js.map' },
26336 error stack: 'Error: EPERM: operation not permitted, unlink \'H:\angular-material-app-master\node_modules\.staging\@angular\compiler-f002f831\bundles\compiler.umd.min.js.map\'',
26336 error errno: -4048,
26336 error code: 'EPERM',
26336 error syscall: 'unlink',
26336 error path: 'H:\angular-material-app-master\node_modules\.staging\@angular\compiler-f002f831\bundles\compiler.umd.min.js.map',
26336 error parent: 'angular-material-app' }
26337 error The operation was rejected by your operating system.
26337 error It's possible that the file was already in use (by a text editor or antivirus),
26337 error or that you lack permissions to access it.
26337 error
26337 error If you believe this might be a permissions issue, please double-check the
26337 error permissions of the file and its containing directories, or try running
26337 error the command again as root/Administrator (though this is not recommended).
26338 verbose exit [ -4048, true ]

I try to do with administrator,but also error

npm http fetch GET 200 https://registry.npmjs.org/smart-buffer 13221ms
npm http fetch GET 200 https://registry.npmjs.org/concat-stream 134206ms
npm WARN tarball tarball data for https://registry.npmjs.org/grpc/-/grpc-1.13.1.tgz (sha512-yl0xChnlUISTefOPU2NQ1cYPh5m/DTatEUV6jdRyQPE9NCrtPq7Gn6J2alMTglN7ufYbJapOd00dvhGurHH6HQ==) seems to be corrupted. Trying one more time.
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 1824274ms
npm ERR! path C:\Users\peng\AppData\Local\Temp\npm-4672-a4c6ef20\unpack-ae2ffde8\deps\grpcsrc\boringssl\crypto_test_data.cc
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\peng\AppData\Local\Temp\npm-4672-a4c6ef20\unpack-ae2ffde8\deps\grpcsrc\boringssl\crypto_test_data.cc'
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Users\peng\AppData\Local\Temp\npm-4672-a4c6ef20\unpack-ae2ffde8\deps\grpcsrc\boringssl\crypto_test_data.cc'
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Users\peng\AppData\Local\Temp\npm-4672-a4c6ef20\unpack-ae2ffde8\deps\grpcsrc\boringssl\crypto_test_data.cc'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\Users\peng\AppData\Local\Temp\npm-4672-a4c6ef20\unpack-ae2ffde8\deps\grpc\src\boringssl\crypto_test_data.cc' },
npm ERR! isOperational: true,
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink \'C:\Users\peng\AppData\Local\Temp\npm-4672-a4c6ef20\unpack-ae2ffde8\deps\grpc\src\boringssl\crypto_test_data.cc\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\Users\peng\AppData\Local\Temp\npm-4672-a4c6ef20\unpack-ae2ffde8\deps\grpc\src\boringssl\crypto_test_data.cc',
npm ERR! parent: '@firebase/firestore' }
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).
npm timing npm Completed in 1829064ms

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\peng\AppData\Roaming\npm-cache_logs\2018-08-19T15_15_24_624Z-debug.log

H:\angular-material-app-master>

I was able to fix this by running the command prompt/bash as admin and closing VSCode!
Seems like VSCode was locking some files.
Potentially something else could be locking these files for you.

i have the same issue, while installation of node-sass

npm ERR! path C:\Projects\node_modules@angular\cdk\esm5
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Projects\node_modules@angular\cdk\esm5'
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Projects\node_modules@angular\cdk\esm5'
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Projects\node_modules@angular\cdk\esm5'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\Projects\\node_modules\@angular\cdk\esm5' },
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink \'C:\Projects\\node_modules\@angular\cdk\esm5\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'C:\Projects\\node_modules\@angular\cdk\esm5',
npm ERR! parent: 'marketpricer' }
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\prashant-mishra\AppData\Roaming\npm-cache_logs\2018-10-10T10_44_02_089Z-debug.log

below command worked for me.

npm install --no-bin-links

Any luck here, I have run into the same proble and its crazy that even after reinstallign node and npm i am getting that error :(

you must checkout this files first, if you are working on source control.
package.json , angular.json, app.module.ts
this way worked for me.

i am getting this error please someone solve this

./node_modules/angularfire2/auth.js
Module build failed: Error: EPERM: operation not permitted, open 'C:\Users\Arslan Malik\oshopnode_modules\angularfire2\auth.js'
at Object.openSync (fs.js:448:3)
at Object.readFileSync (fs.js:348:35)
at Storage.provideSync (C:\Users\Arslan Malik\oshopnode_modules\enhanced-resolve\lib\CachedInputFileSystem.js:98:13)
at CachedInputFileSystem.readFileSync (C:\Users\Arslan Malik\oshopnode_modules\enhanced-resolve\lib\CachedInputFileSystem.js:259:32)
at Observable.rxjs_1.Observable.obs [as _subscribe] (C:\Users\Arslan Malik\oshopnode_modules@ngtools\webpacksrc\webpack-input-host.js:35:51)
at Observable._trySubscribe (C:\Users\Arslan Malik\oshopnode_modules\rxjs\internal\Observable.js:44:25)
at Observable.subscribe (C:\Users\Arslan Malik\oshopnode_modules\rxjs\internal\Observable.js:30:22)
at SyncDelegateHost._doSyncCall (C:\Users\Arslan Malik\oshopnode_modules@angular-devkit\coresrc\virtual-fs\host\sync.js:22:20)
at SyncDelegateHost.read (C:\Users\Arslan Malik\oshopnode_modules@angular-devkit\coresrc\virtual-fs\host\sync.js:49:21)
at WebpackCompilerHost.readFileBuffer (C:\Users\Arslan Malik\oshopnode_modules@ngtools\webpacksrc\compiler_host.js:125:44)
at VirtualFileSystemDecorator.readFile (C:\Users\Arslan Malik\oshopnode_modules@ngtools\webpacksrc\virtual_file_system_decorator.js:39:54)
at processResource (C:\Users\Arslan Malik\oshopnode_modules\loader-runner\lib\LoaderRunner.js:202:11)
at iteratePitchingLoaders (C:\Users\Arslan Malik\oshopnode_modules\loader-runner\lib\LoaderRunner.js:158:10)
at runLoaders (C:\Users\Arslan Malik\oshopnode_modules\loader-runner\lib\LoaderRunner.js:365:2)
at NormalModule.doBuild (C:\Users\Arslan Malik\oshopnode_modules\webpack\lib\NormalModule.js:280:3)
at NormalModule.build (C:\Users\Arslan Malik\oshopnode_modules\webpack\lib\NormalModule.js:427:15)

While opening the solution in Visual Studio is locking some configuration files. So sometimes it shows this type of errors. Close the solution opened in VS Code Or any other editor and run the command from cmd prompt will solve the issue.

For running the command from cmd prompt, Just go to your project folder then press Shift + Right-Click then click Open command window here. Then type the npm install...

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MateenKadwaikar picture MateenKadwaikar  路  3Comments

IngvarKofoed picture IngvarKofoed  路  3Comments

JanStureNielsen picture JanStureNielsen  路  3Comments

rajjejosefsson picture rajjejosefsson  路  3Comments

rwillmer picture rwillmer  路  3Comments