android Metro执行时发生错误:编译器\src\emhermesc.js:77

yquaqz18  于 2022-11-03  发布在  Android
关注(0)|答案(3)|浏览(223)

我通过yarn start启动metro。另一个终端我运行yarn android。当应用程序正在安装时,metro终端出现以下错误,metro停止执行:

C:\Users\SAMSUNG\Desktop\ReactNativeProjects\MyApp\node_modules\metro-hermes-compiler\src\emhermesc.js:77
          throw ex;
          ^

Error: EPERM: operation not permitted, lstat 'C:\Users\SAMSUNG\Desktop\ReactNativeProjects\MyApp\node_modules\react-native-gesture-handler\android\build\kotlin\compileDebugKotlin\caches-jvm'
Emitted 'error' event on NodeWatcher instance at:
    at NodeWatcher.<anonymous> (C:\Users\SAMSUNG\Desktop\ReactNativeProjects\MyApp\node_modules\sane\src\node_watcher.js:291:16)
    at FSReqCallback.oncomplete (fs.js:168:21) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'lstat',
  path: 'C:\\Users\\SAMSUNG\\Desktop\\ReactNativeProjects\\MyApp\\node_modules\\react-native-gesture-handler\\android\\build\\kotlin\\compileDebugKotlin\\caches-jvm'
}

当应用程序正在构建时,我再次通过yarn start启动metro。当应用程序构建完成时,发生以下崩溃:

BUNDLE  ./index.js

 ERROR  TypeError: undefined is not an object (evaluating 'InnerNativeModule.installCoreFunctions')
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the
error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
 ERROR  Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication). A frequent cause of the
error is that the application entry file path is incorrect.
      This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.

我什么都不明白。这些问题发生在我试图添加库@react-navigation/drawer及其先决条件时:yarn add react-native-gesture-handler react-native-reanimated

vc6uscn9

vc6uscn91#

在Windows 10上也有同样的问题。更改node_watcher.js为我解决了这个问题。我更改了函数isIgnorableFileError,使其适用于error === null,并在NodeWatcher类中使用了此函数。这些更改远不完美,但现在它起作用了。
第一个猜测-当NodeWatcher和构建同时访问一个文件时的权限问题。
下面是yarn patch-package sane的结果

diff --git a/node_modules/sane/src/node_watcher.js b/node_modules/sane/src/node_watcher.js

index ce90e4e..51b5e9a 100644

--- a/node_modules/sane/src/node_watcher.js

+++ b/node_modules/sane/src/node_watcher.js

@@ -287,7 +287,7 @@ module.exports = class NodeWatcher extends EventEmitter {

     fs.lstat(

       fullPath,

       function(error, stat) {

-        if (error && error.code !== 'ENOENT') {

+        if (!isIgnorableFileError(error)) {

           this.emit('error', error);

         } else if (!error && stat.isDirectory()) {

           // win32 emits usless change events on dirs.

@@ -304,7 +304,7 @@ module.exports = class NodeWatcher extends EventEmitter {

               this.emitEvent(ADD_EVENT, relativePath, stat);

             }

           }

-        } else {

+        } else if (!error) {

           let registered = this.registered(fullPath);

           if (error && error.code === 'ENOENT') {

             this.unregister(fullPath);

@@ -390,9 +390,14 @@ module.exports = class NodeWatcher extends EventEmitter {

  * @private

  */

 function isIgnorableFileError(error) {

+  if (error !== null)

+  {

+    console.log(error + " " + platform)

+  }

   return (

+    error === null ||

     error.code === 'ENOENT' ||

     // Workaround Windows node issue #4337.

-    (error.code === 'EPERM' && platform === 'win32')

+    (error.code === 'EPERM')

   );

 }
z3yyvxxp

z3yyvxxp2#

我也有同样的问题。对我来说,安装watchman解决了这个问题。我的Mac电脑里没有watchman设置。它可能会帮助一些人。

9lowa7mx

9lowa7mx3#

我得到了这个确切的问题,我设法通过清理以前的构建(“android/app/build”删除整个构建文件夹)修复了它。只是以防万一也删除“node_modules”并执行npm iyarn。最后,运行项目yarn start --reset-cache然后yarn android

相关问题