Gio*_*gio 35 android react-native metro-bundler
我正在尝试运行一个使用 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)
Run Code Online (Sandbox Code Playgroud)
安装graceful-fs
(正如另一篇关于同一问题的帖子所推荐的)不会改变任何东西,我仍然遇到同样的错误。
这里可能是什么问题?提前致谢。
Ron*_*tro 52
我在 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
Run Code Online (Sandbox Code Playgroud)
更新
解决我的问题是添加一个决议,package.json
不允许任何库使用“4.2.4”之前的优雅-fs版本。现在它再次与节点 12 一起工作。
PS:不要忘记运行yarn
或npm run install
更新您的.lock
. 如果此解决方案对您不起作用,请在与 Node 12.18.3 上的此问题相关的线程中添加评论
"devDependencies": {
...
},
"resolutions": {
"graceful-fs": "4.2.4"
},
Run Code Online (Sandbox Code Playgroud)
Ber*_*ard 17
我今天在做构建时也得到了这个。(运行节点 12.8.3)
我重新安装了以下软件包:
npm install graceful-fs --save-dev
Run Code Online (Sandbox Code Playgroud)
这就解决了上述问题。
Har*_*lin 16
这里是 Ubuntu 20.04 用户,节点为 16.0.0。当我运行时,我遇到了同样的错误:
> npx create-react-app [my app]
Run Code Online (Sandbox Code Playgroud)
我发现我必须重新安装create-react-app(首先从node_modules中将其删除)才能解决它。
> npm install create-react-app
Run Code Online (Sandbox Code Playgroud)
如果你安装了 nvm,那就更简单了。要检查这一点,请运行
nvm --version
Run Code Online (Sandbox Code Playgroud)
然后安装最新的 lts 版本的节点,运行
nvm install --lts
Run Code Online (Sandbox Code Playgroud)
这对我有用,如果有帮助,请告诉我
小智 5
我在我的两台电脑上都解决了它。需要做更多的工作。
选项1:
C:\Users(your username)\AppData\Roaming
npm clean cache -force
,或npm cache clean -force
在 Windows 上(——现在需要强制清理缓存)选项 2:
C:\Users(your username)\AppData\Roaming
npm clean cache -force
在 linux 或npm cache clean
windows上运行(——现在需要强制清理缓存) 归档时间: |
|
查看次数: |
38195 次 |
最近记录: |