npm - 我无法在 Ionic v3 中安装相机
问题描述
我正在构建一个 Ionic 应用程序,我想在其中使用 cordova 相机插件,因此我输入:
ionic cordova plugin add cordova-plugin-camera
然后我做:
npm install --save @ionic-native/camera
在这里,我收到了以下警告:
npm WARN @ionic-native/camera@5.0.0 requires a peer of @ionic-native/core@5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
之后,当我在 app.module 和提供者列表中包含相机插件时,我收到以下消息:
Error: Invalid provider for the NgModule 'AppModule' - only instances of Provider and Type are allowed, got: [StatusBar, SplashScreen, [object Object], ?[object Object]?]
at syntaxError (http://localhost:8100/build/vendor.js:74769:34)
at http://localhost:8100/build/vendor.js:89925:40
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (http://localhost:8100/build/vendor.js:89893:19)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:8100/build/vendor.js:89463:50)
at JitCompiler._loadModules (http://localhost:8100/build/vendor.js:107787:87)
at JitCompiler._compileModuleAndComponents (http://localhost:8100/build/vendor.js:107748:36)
at JitCompiler.compileModuleAsync (http://localhost:8100/build/vendor.js:107664:37)
at CompilerImpl.compileModuleAsync (http://localhost:8100/build/vendor.js:73605:49)
at PlatformRef.bootstrapModule (http://localhost:8100/build/vendor.js:5747:25)
解决方案
由于 Ionic 4 的发布,为 Ionic 3 安装 Ionic Native 插件需要在为 Ionic 3@4
安装时附加。因此,要解决此问题,请使用 卸载插件npm uninstall --save @ionic-native/camera
,然后重新安装,npm uninstall --save @ionic-native/camera@4
问题将得到解决。
推荐阅读
- java - 如何使用 BFS 正确实现最大权重无关的正树集
- php - 使用队列发送多封电子邮件失败
- r - 预测随机森林 AUC 时出错
- javascript - Tampermonkey Java Script 在 Chrome 控制台中插入和运行
- android - 如何将材料“响应式布局网格”应用于 Android Compose?
- botframework - 使用 MS Bot Framework V4 时如何从虚拟助手取消技能对话框
- python - 使用 Selenium 和 Python 获取 href
- bash - 基于 bash 中的循环操作的带有错误代码的退出脚本
- floating-point - 从我的 Fortran 代码中获得意外的 NaN 输出
- c# - 由于 System.AggregateException 异常,无法启动 asp .net core API