【发布时间】:2019-03-11 00:52:45
【问题描述】:
我正在构建一个 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)
【问题讨论】:
-
我也得到了这个 :c 类型参数 '{ 声明:(typeof HomePage | typeof MyApp)[];进口:(ModuleWithProviders | typeof Browse...' 不可分配给'NgModule'类型的参数。属性'providers'的类型不兼容。类型'(typeof SplashScreen | CameraOriginal | {提供:typeof ErrorHandler; useClass:typeof IonicErr。 ..' 不可分配给类型 'Provider[]'。类型 'typeof SplashScreen | CameraOriginal | { 提供:typeof ErrorHandler; useClass: typeof IonicErro...' 不可分配给类型 'Provider'。类型 'CameraOriginal' 不是可分配给类型“提供者”
-
即使在 ionic 4 发布后我也无法在 Ionic 3 中安装插件
标签: npm ionic3 cordova-plugins ionic-native