Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Error: EPERM: operation not permitted, scandir #17747

Closed
2 of 13 tasks
doberkofler opened this issue Jul 12, 2017 · 76 comments
Closed
2 of 13 tasks

Error: EPERM: operation not permitted, scandir #17747

doberkofler opened this issue Jul 12, 2017 · 76 comments

Comments

@doberkofler
Copy link

doberkofler commented Jul 12, 2017

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

D:\MyDev\ljs_app\trunk\periscope\build>npm i
npm ERR! path D:\MyDev\ljs_app\trunk\periscope\build\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'D:\MyDev\ljs_app\trunk\periscope\build\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'D:\MyDev\ljs_app\trunk\periscope\build\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'D:\\MyDev\\ljs_app\\trunk\\periscope\\build\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'D:\\MyDev\\ljs_app\\trunk\\periscope\\build\\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\doberkofler.LBITS\AppData\Roaming\npm-cache\_logs\2017-07-12T18_53_54_304Z-debug.log

How can the CLI team reproduce the problem?

https://gist.github.com/doberkofler/f24eea4a2d57cefde864ed64556b7bc1.js

supporting information:

  • npm -v prints: 5.2.0
  • node -v prints: 8.1.4
  • npm config get registry prints: http://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: Windows
  • Network issues:
    • Geographic location where npm was run:
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don't use a proxy, but have limited or unreliable internet access.
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).
@jdrake3
Copy link

jdrake3 commented Jul 13, 2017

Me too, but node -v prints: v6.10.0

@kenany kenany added the support label Jul 13, 2017
@doberkofler
Copy link
Author

Unfortunately this problem is so nasty, it forced me to revert back to npm 4. I loved the performance of version 5 and would really hope to get this fixed. Thank you!

@marcins
Copy link
Contributor

marcins commented Jul 16, 2017

This seems to be a duplicate of #17671, or at least has the same symptoms. That issue has more detail though.

@marcins marcins marked this as a duplicate of #17671 Jul 16, 2017
@doberkofler
Copy link
Author

Tested again with:

  • npm -v prints: 5.3.0
  • node -v prints: 8.3.0

but the problem persists and had to move back to npm 4!

@doberkofler
Copy link
Author

@marcins I'm not so sure if this is really the same problem...

@doberkofler
Copy link
Author

I have some news that might (hopefully) improve the chances to track this problem down.
I discovered that after cleaning the cache the first installation works as expected but when later installing the same dependencies in another project the error arises. In my opinion and given the fact that the problems seems to happen with optional dependencies, this suggests a problem in the resolution/caching of the resolved optional dependencies. I hope this helps and hope even more to have this fixed and finally being able to use the latest (and greatest) npm version.

@RGTGT
Copy link

RGTGT commented Aug 17, 2017

Same issue here:

  • npm -v prints: 5.3.0
  • node -v prints: v6.11.1

I'm on windows

Although, upgrading to node v6.11.2 fixed my errors.

@srsgores
Copy link

I get this too, on Windows. Even on the latest 8.4.0. I'll see if downgrading to LTS 6.11.2 fixes this.

@srsgores
Copy link

srsgores commented Aug 24, 2017

I still get the same problem on LTS 6.11.2 (so this error prevents me from using Gatsby entirely on WIndows):

npm ERR! Windows_NT 10.0.15063
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install" "gatsby"
npm ERR! node v6.11.2
npm ERR! npm v3.10.10
npm ERR! path C:\Users\user\github\project\node_modules\gatsby\bin\gatsby.js
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\user\github\project\node_modules\gatsby\bin\gatsby.js'
npm ERR! enoent ENOENT: no such file or directory, chmod 'C:\Users\user\github\project\node_modules\gatsby\bin\gatsby.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\user\github\project\npm-debug.log

@marcins
Copy link
Contributor

marcins commented Aug 24, 2017

@srsgores I don't think that's the same issue, this issue relates to an EPERM operation not permitted error (which usually occurs intermittently when installing fsevents).

It looks like in this case the gatsby.js binary is assuming the chmod command exists, which is a Unix command and doesn't exist on Windows.

@srsgores
Copy link

@marcins, I definitely do get the error:

npm WARN Error: EPERM: operation not permitted, scandir 'C:\Users\user\github\project\node_modules\find-up\node_modules'
npm WARN { Error: EPERM: operation not permitted, scandir 'C:\Users\user\github\project\node_modules\find-up\node_modules'
npm WARN stack: 'Error: EPERM: operation not permitted, scandir 'C:\Users\user\github\project\node_modules\find-up\node_modules'',
npm WARN errno: -4048,
npm WARN code: 'EPERM',
npm WARN syscall: 'scandir',
npm WARN path: 'C:\Users\user\github\project\node_modules\find-up\node_modules' }

@haldhafari82
Copy link

haldhafari82 commented Aug 27, 2017

if using cygwin:

runas root

@akshayefusion
Copy link

Facing the same issue
npm ERR! path D:\xampp\htdocs\east-hem\front\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 'D:\xampp\htdocs\east-hem
\front\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! { Error: EPERM: operation not permitted, unlink 'D:\xampp\htdocs\east-
hem\front\node_modules\fsevents\node_modules\ansi-regex\package.json'
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink 'D:\xampp\ht
docs\east-hem\front\node_modules\fsevents\node_modules\ansi-regex\package
.json'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'D:\xampp\htdocs\east-hem\front\node_modules\fsevents\no
de_modules\ansi-regex\package.json' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

@adamzhu-xs
Copy link

Got same issue. Seems NPM try to scan folder \test-app\node_modules\fsevents\node_modules which doesn't exist.

windows 7
node v6.10.3
npm 5.3.0

  1. If i keep trying to install package, 1 out of 5 installing will work.
  2. If i clean NPM cache first by force, next npm install will work.

@AleCaste
Copy link

I was getting the same error on Windows 7 and npm 5.3.0.
I ran npm cache verify and after that I had no problems installing modules.
I decided not to try npm cache clean --force since I did not want to empty the cache.

Give it a go to check if it helps.

@rossbu
Copy link

rossbu commented Sep 11, 2017

Same error with below Env:
Win 7 Pro
Node 8.2.1
NPM 5.3.X
vscode terminal with git bash.
( Note: be alert how you open vscode and terminal and what user do you use to open it)

Solution: ( with VS Code terminal + git bash )

  1. remove node_modules
  2. npm cache verify
  3. npm install
  4. ng serve.

Error is gone. good luck.

@billysean
Copy link

billysean commented Sep 13, 2017

having this issue as well.. NPM 5.3, node 8.4
tried cleaning cache, verifying cache as suggested but problem still preserve..
on second thought, my problem is gone when using windows powershell admin

@raucuqua
Copy link

work very fine
npm 5.3 + node 6

@adriatic
Copy link

I am fighting this for more than a year, so clearly this is independent of npm and or node version. Just now, I got:

λ npm install
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated express@2.5.11: express 2.x series is deprecated
npm WARN deprecated connect@1.9.2: connect 1.x series is deprecated
npm ERR! path H:\work\aurelia-tools\acb-samples\skeleton-typescript-cli\node_modules\fsevents\node_modules\getpass\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'H:\work\aurelia-tools\acb-samples\skeleton-typescript-cli\node_modules\fsevents\node_modules\getpass\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'H:\work\aurelia-tools\acb-samples\skeleton-typescript-cli\node_modules\fsevents\node_modules\getpass\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'H:\\work\\aurelia-tools\\acb-samples\\skeleton-typescript-cli\\node_modules\\fsevents\\node_modules\\getpass\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'H:\\work\\aurelia-tools\\acb-samples\\skeleton-typescript-cli\\node_modules\\fsevents\\node_modules\\getpass\\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\nik\AppData\Roaming\npm-cache\_logs\2017-09-15T21_38_03_356Z-debug.log

Then, I just removed the node_modules and run nom install again:

npm install
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated express@2.5.11: express 2.x series is deprecated
npm WARN deprecated connect@1.9.2: connect 1.x series is deprecated
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

added 1042 packages in 69.35s

I am pretty sure that there is more than one source of this same manifestation, that include the "interference" from running instance of vscode as well as various virus and malware checkers (I have both of them running - and at this time, vscode was not).

The problem is obviously npm's failure to execute:

scandir 'H:\work\aurelia-tools\acb-samples\skeleton-typescript-cli\node_modules\fsevents\node_modules\getpass\node_modules'

because "some other running process* has a lock on that folder. This problem is further compounded by the fact that this folder is temporary, making it impossible to look for the lock owner after the fact. Probably the best approach would be that npm "learns" some of the tricks explained in https://superuser.com/questions/117902/find-out-which-process-is-locking-a-file-or-folder-in-windows article and dump that data into its log.

@marcins
Copy link
Contributor

marcins commented Sep 16, 2017

@adriatic is this with npm 5.4.2? That version (just released) has a fix for this issue, so would be good to know If it isn’t fixed.

@akshay-js
Copy link

After downgrade npm version to 4.6, now working

@doberkofler
Copy link
Author

@marcins I've tried with the latest npm 5.4.2 version and node 8.5.0 but the error persists and I one again had to move back to npm 4.

@corvinrok
Copy link

Is there a problem with downgrading to 4.6 when you are running node 8.5.0? I have the same problem listed in this thread with no version 5.3.x or 5.4.x working , but downgrading back to npm 4.x was giving me other errors before and I didn't know if node 8.5.0 has some sort of minimum version requirement on the npm version it would work with....

@corvinrok
Copy link

I can confirm that downgrading to the specific version of npm 4.6.1 did work for me, running a node 8.5.0 project.

@Callie-C-Wang
Copy link

Hi @DJviolin
Your solution did not work for me.
I can install the @angular/cli with -f option
However, when I try to create new application by command ng new projName, it threw out error.

Here is the error message when I trying to install @angular/cli without -f option

node-sass@4.5.3 install C:\Users\cwang\AppData\Roaming\npm\node_modules@angular\cli\node_modules\node-sass
node scripts/install.js

uglifyjs-webpack-plugin@0.4.6 postinstall C:\Users\cwang\AppData\Roaming\npm\node_modules@angular\cli\node_modules\webpack\node_modules\uglifyjs-webpack-plugin
node lib/post_install.js

npm WARN Error: EPERM: operation not permitted, scandir 'C:\Users\cwang\AppData\Roaming\npm\node_modules@angular\cli\node_modules'
npm WARN { Error: EPERM: operation not permitted, scandir 'C:\Users\cwang\AppData\Roaming\npm\node_modules@angular\cli\node_modules'
npm WARN stack: 'Error: EPERM: operation not permitted, scandir 'C:\Users\cwang\AppData\Roaming\npm\node_modules\@angular\cli\node_modules'',
npm WARN errno: -4048,
npm WARN code: 'EPERM',
npm WARN syscall: 'scandir',
npm WARN path: 'C:\Users\cwang\AppData\Roaming\npm\node_modules\@angular\cli\node_modules' }
npm ERR! file C:\windows\system32\cmd.exe;
npm ERR! path C:\windows\system32\cmd.exe;
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn C:\windows\system32\cmd.exe;
npm ERR! uglifyjs-webpack-plugin@0.4.6 postinstall: node lib/post_install.js
npm ERR! spawn C:\windows\system32\cmd.exe; ENOENT
npm ERR!
npm ERR! Failed at the uglifyjs-webpack-plugin@0.4.6 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Any one know how to solve this problem?
Thank you.

@steffanhalv
Copy link

@corvinrok It was opened a new issue on this #19004 which is open and @kenany added support label and windows label to this and the opened issue (which is not closed..). None still asigned thought

@corvinrok
Copy link

@steffanhalv thank you.

@warrenminano
Copy link

Successful installed using

npm cache verify
npm install --force <package>

npm -v prints: 5.5.1
node -v prints: 8.5.0

@OkanaByte
Copy link

npm ERR! path C:\xampp\htdocs\booksnotes\node_modules\fsevents\node_modules\dashdash\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'C:\xampp\htdocs\booksnotes\node_modules\fsevents\node_modules\dashdash\node_modules'
npm ERR! { Error: EPERM: operation not permitted, scandir 'C:\xampp\htdocs\booksnotes\node_modules\fsevents\node_modules\dashdash\node_modules'
npm ERR! stack: 'Error: EPERM: operation not permitted, scandir 'C:\xampp\htdocs\booksnotes\node_modules\fsevents\node_modules\dashdash\node_modules'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'scandir',
npm ERR! path: 'C:\xampp\htdocs\booksnotes\node_modules\fsevents\node_modules\dashdash\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\Wolf\AppData\Roaming\npm-cache_logs\2017-11-05T23_53_40_753Z-debug.log

Package install failed, see above.

@matthiku
Copy link

matthiku commented Nov 6, 2017

node v8.9.0
npm v5.5.1
were just installed on Windows 10. I am using Git Bash.
Installed vue-cli,
then created a new project use vue-init webpack-simple stocktrader,
then did npm install
and npm run dev.
I broke out of the dev server (hit Ctrl-C twice!) and tried to install vuex:
npm install --save-dev vuex and got this error:

npm ERR! path C:\laragon\www\stockTrader\node_modules\fsevents\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir 'C:\laragon\www\stockTrader\node_modules\fsevents\node_modules'
npm ERR!  { Error: EPERM: operation not permitted, scandir 'C:\laragon\www\stockTrader\node_modules\fsevents\node_modules'
npm ERR!   stack: 'Error: EPERM: operation not permitted, scandir \'C:\\laragon\\www\\stockTrader\\node_modules\\fsevents\\node_modules\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'scandir',
npm ERR!   path: 'C:\\laragon\\www\\stockTrader\\node_modules\\fsevents\\node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

Then I did a npm cache verify and tried to install vuex again, and bingo! it worked.

@ewhitmore
Copy link

ewhitmore commented Nov 6, 2017

FYI - this issue has been reposted here: #19004 as this issue was closed by the bot. Please comment there so the bot doesn't close that ticket as well.

@puttuo
Copy link

puttuo commented Nov 20, 2017

In Windows, start the command line using "Run as administrator" seems can solve this issue.

@EwertonDutra
Copy link

For me, every time I run a command it gives an error. Then the second time it works out.
Ex: npm i --save-dev webpack@1.14.0 webpack-dev-server@1.16.2

1 st wrong
Right 2

I use windows 7 x64
npm --v 5.5.1
CMD: cmder

@mrTurkay
Copy link

I solved that issue with yarn

then you need to set default ng promt as yarn

@mseltene
Copy link

mseltene commented Nov 22, 2017

This worked for me:
npm install scandir -g

and then continue, such as npm install.

@EwertonDutra
Copy link

@micsel The command works
Thanks for the help, I've done 2 tests here ... I hope the problem does not come back

@IzikM
Copy link

IzikM commented Nov 22, 2017

Beautifull solution. Worked here, too.
After executing "npm install scandir -g" like @micsel suggested.
Thanks @micsel.

@IzikM
Copy link

IzikM commented Nov 23, 2017

Correction. After it worked - the error reared its head up again.
Following @micsel's example I had to run as an admin and execute:
"npm cache verify"
and then:
"npm install scandir rmdir fsync --save"
This worked.
Hoping it sticks :-)

@matthiku
Copy link

matthiku commented Nov 25, 2017

I think this whole issue is just an intermittent problem related to some sync issues between Git bash and Windows.
If the error happens, just repeat your last command and chances are high that it works then.
You might also want to run a npm cache verify in between to help matters settle.

@ajochems
Copy link

ajochems commented Dec 1, 2017

In my case it was caused by Windows Defender realtime protection on Windows 10. As soon as i added an exception for the node.exe process all errors where gone!

@matthiku
Copy link

matthiku commented Dec 1, 2017

Repeat the last command and problem is solved:

clipboarder 2017 12 01

And it's always this annoying 'fsevent' package that causes it!!

@jerronvwh
Copy link

worked after
npm install npm@5.6 -g

@bulbul16
Copy link

bulbul16 commented Dec 2, 2017

I was facing the same issue :What I have done is clear cashe of npm and its working for me. Please do the following

  1. Uninstall node
  2. Run the following command %programfiles%\nodejs and delete files
  3. Run %appdata%\npm and delete files
  4. Run %appdata%\npm-cache and delete files
  5. Install node again whatever version you are willing to
  6. Install angular cli again with this command
    npm install -g angular-cli
    Now try ng new app
    It's working for me. Happy coding :)

@hsingh419
Copy link

upgrading with npm install npm@5.6 -g worked for me

Thanks!

@JimEastburn
Copy link

npm install npm@5.6 -g worked for me

@cruzeiro99
Copy link

Windows 10, I did run the CMD as root and I type
npm install babel-core@6 and works fine.
Without CMD as root I got that error related above

@zkat
Copy link
Contributor

zkat commented Dec 8, 2017

This seems fixed, so I'm gonna go ahead and lock it, since it's already closed.

@npm npm locked and limited conversation to collaborators Dec 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests