expo-cli icon indicating copy to clipboard operation
expo-cli copied to clipboard

File watcher permissions error on Windows causes crash

Open katontech opened this issue 5 years ago • 34 comments

Description

Expo server crashes frequently. I was reporting that I had the same symptoms as Issue #519, but that was my mistake.

Expected Behavior

The server crashes while running expo start and connecting to the device.

Observed Behavior

events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, lstat '<path-to-the-project>\table.xsl.tmp'
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.<anonymous> (<path-to-the-project>\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqCallback.oncomplete (fs.js:167:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: '<path-to-the-project>\\table.xsl.tmp'
}

I'm not sure what the file "table.xsl.tmp" came from. This file name is shown in the error message of all my projects. Fortunately, I've found that I can avoid a crash by leaving an empty file with this name in my project root.

Environment

  Expo CLI 3.19.2 environment info:
    System:
      OS: Windows 10 10.0.18363
    Binaries:
      Node: 12.16.2 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.4 - C:\Users\<user-name>\AppData\Roaming\npm\yarn.CMD
      npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.6.0.0 AI-192.7142.36.36.6308749
    npmPackages:
      expo: ^37.0.7 => 37.0.7
      react: ~16.9.0 => 16.9.0
      react-native: https://github.com/expo/react-native/archive/sdk-37.0.0.tar.gz => 0.61.4

The connection devices are as follows.

  • iPhone 6 (iOS 12.4.5)
  • iOS simulator (iOS 13.3) [iPhone 11, iPad Pro (9.7-inch), ...]
  • Android emulator (Android 10)

katontech avatar Apr 28 '20 06:04 katontech

also see: https://github.com/oblador/react-native-vector-icons/issues/354

you can try running as administrator as suggested in that issue

brentvatne avatar Apr 28 '20 18:04 brentvatne

maybe we can watch EPERM errors and link people to some expo.fyi doc that explains how they can work around this

brentvatne avatar Apr 28 '20 18:04 brentvatne

I tried expo start in admin console and it crashed with the exact same error message. As a development user, my account has full permissions on the '<path-to-the-project> \ table.xsl.tmp' file. Why does expo start try to touch the '<path-to-the-project> \ table.xsl.tmp' file and it fails? :-)

katontech avatar Apr 29 '20 03:04 katontech

as far as i know it does not, seems like something with your machine. feel free to clone the repo and install node_modules and scan for that file everywhere and you won't find it. when in doubt it's generally some weird windows thing

brentvatne avatar Apr 29 '20 20:04 brentvatne

I found that the new project created by expo init with [email protected] does not reproduce the symptoms. So, after deleting the node_modules of the project where the problem occurred and running npm i, the symptom did not reappear in this project. This project was created by [email protected], so some circumstances may have changed.

Thank you for your cooperation.

katontech avatar Apr 30 '20 09:04 katontech

Still having the same problem with version 3.20.0

SohailHaqyar avatar Apr 30 '20 10:04 SohailHaqyar

Unfortunately, it happened again in my project. On the other hand, it has not been reproduced yet in the project that only did expo init with [email protected].

katontech avatar Apr 30 '20 11:04 katontech

Follow-up: Even in the project that just did expo init with [email protected], the symptom was reproduced about 1 hour after starting the connection with the device. Then restart the bundler with the'r'key and the symptom reproduced in a few minutes.

katontech avatar Apr 30 '20 15:04 katontech

This symptom is reproduced in the project created by [email protected] expo init, but the frequency is obviously lower than before. I have a project that is stable for more than 18 hours after expo start.

In a symptomatic project, expo start with [email protected] and crash in tens of minutes to minutes.

katontech avatar May 01 '20 09:05 katontech

I'm not sure if it's related but I get a similar error as well. Either expo randomly crashes or crashes when I add a new package to my project.

using [email protected] project packages using React Native and expo are @35.0.0

Running application on LG-H830.
events.js:173

    throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, lstat 'C:\Users\josep\keepbass-rn\node_modules\@babel\generator\node_modules\.bin'
Emitted 'error' event at:
    at NodeWatcher.<anonymous> (C:\Users\josep\keepbass-rn\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqCallback.oncomplete (fs.js:148:21)

sortinousn avatar May 07 '20 03:05 sortinousn

it sounds like you need to fix permissions on your machine or run everything as admin. i think the fix here isn't something we can build into expo-cli, but rather to guide people to an appropriate guide. i'm not familiar enough with windows to know what the best approach is here. cc @byCedric

brentvatne avatar Jul 16 '20 23:07 brentvatne

I also occasionally see an error that lstat fails when accessing node_modules\.bin, but it doesn't continue. Rather than a static permission setting issue, maybe other processing for node_modules was happening in the background.

katontech avatar Jul 17 '20 06:07 katontech

This error is making my life hell for react development. building an apk, is becoming a nightmare for me.

sonuame avatar Jul 20 '20 20:07 sonuame

events.js:292 throw er; // Unhandled 'error' event ^

Error: EPERM: operation not permitted, lstat 'xxxxx\android\app\build\generated\assets\react' Emitted 'error' event on NodeWatcher instance at: at NodeWatcher. (xxxxxx\node_modules\sane\src\node_watcher.js:291:16) at FSReqCallback.oncomplete (fs.js:167:21) { errno: -4048, code: 'EPERM', syscall: 'lstat', path: 'xxxxx\android\app\build\generated\assets\react' }

sonuame avatar Jul 20 '20 20:07 sonuame

events.js:287 throw er; // Unhandled 'error' event ^

Error: EPERM: operation not permitted, lstat 'C:\Users\KIIT\Desktop\ProApp\node_modules.bin\atob' Emitted 'error' event on NodeWatcher instance at: at NodeWatcher. (C:\Users\KIIT\Desktop\ProApp\node_modules\sane\src\node_watcher.js:291:16) at FSReqCallback.oncomplete (fs.js:167:21) { errno: -4048, code: 'EPERM', syscall: 'lstat', path: 'C:\Users\<userName>\Desktop\ProApp\node_modules\.bin\atob' } ^ I'm getting this error.

ShreyaDhir avatar Sep 06 '20 12:09 ShreyaDhir

I had to quit Expo and user react-native cli in the end

sonuame avatar Sep 06 '20 12:09 sonuame

@EvanBacon @brentvatne I also get the same issue .

Logs for your project will appear below. Press Ctrl+C to exit.
Finished building JavaScript bundle in 5920ms.
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, lstat 'C:\MyProjects\<ReactNative-project-directory>\table.xsl.tmp
Emitted 'error' event at:
    at NodeWatcher.<anonymous> (C:\MyProjects\<ReactNative-project-directory>\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqWrap.oncomplete (fs.js:153:21)

Environment

  • Windows 10 : 10.0.18362 Build 18362
  • Yarn : 1.22.10
  • Expo-CLI : 3.27.10
  • Security : Kaspersky Security Cloud (File Protection is disabled )

My Questions

  1. Why does it try to write a file (table.xsl.tmp) in to AppDirectory ??
  2. What type of permission is needed ?
  3. Does it happen because it is an untrusted file ? ( I mean , are .tmp files untrusted ?)

NisugaJ avatar Oct 04 '20 04:10 NisugaJ

@EvanBacon @brentvatne I also get the same issue .

Logs for your project will appear below. Press Ctrl+C to exit.
Finished building JavaScript bundle in 5920ms.
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, lstat 'C:\MyProjects\<ReactNative-project-directory>\table.xsl.tmp
Emitted 'error' event at:
    at NodeWatcher.<anonymous> (C:\MyProjects\<ReactNative-project-directory>\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqWrap.oncomplete (fs.js:153:21)

Environment

  • Windows 10 : 10.0.18362 Build 18362
  • Yarn : 1.22.10
  • Expo-CLI : 3.27.10
  • Security : Kaspersky Security Cloud (File Protection is disabled )

My Questions

  1. Why does it try to write a file (table.xsl.tmp) in to AppDirectory ??
  2. What type of permission is needed ?
  3. Does it happen because it is an untrusted file ? ( I mean , are .tmp files untrusted ?)

Tested now. Expo refreshes my app-changes successfully if VS Code is closed when executing expo start. But I had to add my code changes via Notepad++. I think this issue comes because of my VS Code. Soon after I opened VS Code and did a file change, this error prompted again. Expo-server is shut-down by VS Code 😄🤣. Or maybe I should configure VS Code settings for files R/W.

Hope this result helps you 😃

NisugaJ avatar Oct 04 '20 04:10 NisugaJ

@EvanBacon @brentvatne I also get the same issue .

Logs for your project will appear below. Press Ctrl+C to exit.
Finished building JavaScript bundle in 5920ms.
events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, lstat 'C:\MyProjects\<ReactNative-project-directory>\table.xsl.tmp
Emitted 'error' event at:
    at NodeWatcher.<anonymous> (C:\MyProjects\<ReactNative-project-directory>\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqWrap.oncomplete (fs.js:153:21)

Environment

  • Windows 10 : 10.0.18362 Build 18362
  • Yarn : 1.22.10
  • Expo-CLI : 3.27.10
  • Security : Kaspersky Security Cloud (File Protection is disabled )

My Questions

  1. Why does it try to write a file (table.xsl.tmp) in to AppDirectory ??
  2. What type of permission is needed ?
  3. Does it happen because it is an untrusted file ? ( I mean , are .tmp files untrusted ?)

Tested now. Expo refreshes my app-changes successfully if VS Code is closed when executing expo start. But I had to add my code changes via Notepad++. I think this issue comes because of my VS Code. Soon after I opened VS Code and did a file change, this error prompted again. Expo-server is shut-down by VS Code 😄🤣. Or maybe I should configure VS Code settings for files R/W.

Hope this result helps you 😃

When tried with Atom, can do some refreshing changes, but crashed prompting the same issue.

NisugaJ avatar Oct 04 '20 05:10 NisugaJ

It is interesting that the phenomenon involving the same file table.xsl.tmp as in my environment also occurred in another environment. I've also run into the fact that it doesn't reappear in my other PC environment with the same configuration. From this, I suspect that some external command executed by expo-cli is affected by the environmental difference.

On the other hand, I'm not too worried because I can avoid this error just by creating an empty table.xsl.tmp file.

katontech avatar Oct 04 '20 05:10 katontech

It is interesting that the phenomenon involving the same file table.xsl.tmp as in my environment also occurred in another environment. I've also run into the fact that it doesn't reappear in my other PC environment with the same configuration. From this, I suspect that some external command executed by expo-cli is affected by the environmental difference.

On the other hand, I'm not too worried because I can avoid this error just by creating an empty table.xsl.tmp file.

Thank you @katontech . You saved my day. Created table.xsl.tmp and it works like a charm now😍.

NisugaJ avatar Oct 04 '20 06:10 NisugaJ

@byCedric @fson - can one of you investigate why this table.xsl.tmp thing is going on? we do not refer to this in any way inside of our codebase so i'm confused

brentvatne avatar Oct 04 '20 06:10 brentvatne

I don't even know that. I also searched for the installed expo-cli code and know that table.xsl.tmp is not directly referenced. Since expo-cli seems to work using various external tools, I imagine that there may be environmental factors that affect them.

katontech avatar Oct 04 '20 10:10 katontech

None of our code, or our dependencies, refer to the file table.xsl.tmp or table.xsl. I'm not sure why this suddenly pops up for you. If someone is willing to share his/her package.json when they encounter this, I'd be happy to look into that.

We do know there are "weird behaviors" of file permissions on Windows. For example, creating a symbolic link doesn't work on Windows unless you run terminal with administrator privileges. I would heavily recommend to try that if you run into any EPERM errors with node.

But again, let's try to find the source of the table.xsl. If we find this, we can investigate why this is happening for some people and fix that instead. Fixing Windows EPERM issues isn't really possible on our end, this is a limitation from Windows itself. You can try running in WSL, that should work without problems 😄

byCedric avatar Oct 06 '20 14:10 byCedric

table.xsl.tmp is also a mystery to me. Naturally, I searched for table.xsl. * Somewhere on my PC, but I couldn't find it. I was wondering if it was a phenomenon specific to my environment, but I am interested because there were other people who appeared table.xsl.tmp in the error message.

The phenomenon occurred by repeating the source update after expo start even if it was just after creating the project with expo init, so I think that there is no cause in the contents of package.json.

You seem to be skeptical about the "strange behavior" of Windows file permissions, but I think this is a different story as it can be reproduced in a terminal with administrator privileges.

Thanks for your comment. :-)

katontech avatar Oct 06 '20 15:10 katontech

events.js:287 throw er; // Unhandled 'error' event ^

Error: EPERM: operation not permitted, lstat 'C:\Users\KIIT\Desktop\ProApp\node_modules.bin\atob' Emitted 'error' event on NodeWatcher instance at: at NodeWatcher. (C:\Users\KIIT\Desktop\ProApp\node_modules\sane\src\node_watcher.js:291:16) at FSReqCallback.oncomplete (fs.js:167:21) { errno: -4048, code: 'EPERM', syscall: 'lstat', path: 'C:\Users\Desktop\ProApp\node_modules.bin\atob' } ^ I'm getting this error.

i had the same Error .i jhave kasperskysecurity and I disabled its file protection service .then eeror was gone

Ttecs avatar Nov 19 '20 16:11 Ttecs

This is happening to me as well. I tried to create a new project but still. Also occurring on web app w/o android emulate. It suddenly happening, after 1-2 minutes of uasge

Tech info: Windows 10. IDE: IntelliJ / VSCode Run expo via IDE terminal/CMD with admin permissions

Error:

Error: EPERM: operation not permitted, lstat 'D:\...\app\pages\MainPage.js~'
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.<anonymous> (D:\...\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqCallback.oncomplete (node:fs:198:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'D:\\...\\app\\pages\\MainPage.js~'
}

tavorperry avatar Feb 22 '22 17:02 tavorperry

Am also getting a similar error:

Doesn't occur on web app for me but it does happen quite often when tunneled to my ios device.

Error: EPERM: operation not permitted, lstat 'C:\Users\_\PersonalProjects\freends\screens\LoginScreen.tsx~'
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.<anonymous> (C:\Users\_\PersonalProjects\freends\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqCallback.oncomplete (node:fs:198:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'C:\\Users\\_\\PersonalProjects\\freends\\screens\\LoginScreen.tsx~'
}

ricjohn-acosta avatar Mar 01 '22 05:03 ricjohn-acosta

I'm getting this error

C:\Development\App\OfficeProjects\TillelIApp\node_modules\metro-hermes-compiler\src\emhermesc.js:77
          throw ex;
          ^

Error: EPERM: operation not permitted, lstat 'C:\Development\App\OfficeProjects\TillelIApp\.git\objects\maintenance.lock'       
Emitted 'error' event on NodeWatcher instance at:
    at C:\Development\App\OfficeProjects\TillelIApp\node_modules\jest-haste-map\build\watchers\NodeWatcher.js:275:14
    at FSReqCallback.oncomplete (node:fs:198:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'C:\\Development\\App\\OfficeProjects\\TillelIApp\\.git\\objects\\maintenance.lock'
}
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

SohelIslamImran avatar May 31 '22 16:05 SohelIslamImran

I'm getting this error

C:\Development\App\OfficeProjects\TillelIApp\node_modules\metro-hermes-compiler\src\emhermesc.js:77
          throw ex;
          ^

Error: EPERM: operation not permitted, lstat 'C:\Development\App\OfficeProjects\TillelIApp\.git\objects\maintenance.lock'       
Emitted 'error' event on NodeWatcher instance at:
    at C:\Development\App\OfficeProjects\TillelIApp\node_modules\jest-haste-map\build\watchers\NodeWatcher.js:275:14
    at FSReqCallback.oncomplete (node:fs:198:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'C:\\Development\\App\\OfficeProjects\\TillelIApp\\.git\\objects\\maintenance.lock'
}
error Command failed with exit code 7.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

yep getting the same error

oleg1994 avatar Jun 15 '22 09:06 oleg1994