gpt4 book ai didi

android - TypeError : cb. apply 不是函数

转载 作者:行者123 更新时间:2023-12-03 13:24:28 26 4
gpt4 key购买 nike

我正在尝试运行使用 Metro Bundler 的现有 React Native 项目。我的操作系统是 Ubuntu 20.04,我尝试在物理 Android 设备和使用 Android Studio 创建的 Android 模拟器上运行该应用程序。
我已经成功克隆了项目的 repo,安装了它的依赖项(yarn),构建了应用程序(react-native run-android),并在我的手机和模拟器上打开了应用程序。但是,运行 react-native start错误提示 TypeError: cb.apply is not a function .这是我在运行 react-native start 时得到的完整信息和错误。 :

$ react-native start
warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- rn-fetch-blob: https://npmjs.com/package/rn-fetch-blob
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
┌──────────────────────────────────────────────────────────────────────────────┐
│ │
│ Running Metro Bundler on port 8081. │
│ │
│ Keep Metro running while developing on any JS projects. Feel free to │
│ close this tab and run your own Metro instance if you prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└──────────────────────────────────────────────────────────────────────────────┘

warn Your project is using deprecated "rnpm" config that will stop working from next release. Please use a "react-native.config.js" file to configure the React Native CLI. Migration guide: https://github.com/react-native-community/cli/blob/master/docs/configuration.md
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- rn-fetch-blob: https://npmjs.com/package/rn-fetch-blob
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
Looking for JS files in
/home/ggiuffre/Documents/squib/app

Loading dependency graph, done.
BUNDLE [android, dev] ./index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)/home/ggiuffre/Documents/squib/app/node_modules/@react-native-community/cli/node_modules/graceful-fs/polyfills.js:285
if (cb) cb.apply(this, arguments)
^

TypeError: cb.apply is not a function
at /home/ggiuffre/Documents/squib/app/node_modules/@react-native-community/cli/node_modules/graceful-fs/polyfills.js:285:20
at FSReqCallback.oncomplete (fs.js:169:5)

安装 graceful-fs (正如 another post 推荐的关于同样的问题)没有改变任何东西,我仍然得到同样的错误。
这里可能是什么问题?提前致谢。

最佳答案

我在 CI 上遇到了非常相似的问题,但它在我的本地机器(节点 13)上正常工作。在 CI 中,当使用我两个月前发布的代码在 CircleCI 或 AppCenter 上构建项目时,它会引发以下错误。它只是没有意义,就像节点已经动态损坏了。
我用节点 10、12 和 14 测试了相同的代码,但现在它只适用于节点 10 (10.22.0)。
我遇到的错误:

/home/circleci/my-app/node_modules/@react-native-community/cli/node_modules/graceful-fs/polyfills.js:285
if (cb) cb.apply(this, arguments)
^

TypeError: cb.apply is not a function
at /home/circleci/my-app/node_modules/@react-native-community/cli/node_modules/graceful-fs/polyfills.js:285:20
at FSReqCallback.oncomplete (fs.js:169:5)

> Task :app:bundleReleaseJsAndAssets FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> Process 'command 'node'' finished with non-zero exit value 1
更新
解决我的问题的方法是为 package.json 添加一个分辨率。不允许任何 lib 使用“4.2.4”之前的优雅 fs 版本。现在它再次与节点 12 一起工作。
PS:别忘了运行 yarnnpm run install更新您的 .lock .如果此解决方案不适合您,请在此 thread 中添加评论与节点 12.18.3 上的此问题相关
  "devDependencies": {
...
},
"resolutions": {
"graceful-fs": "4.2.4"
},

关于android - TypeError : cb. apply 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63214997/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com