我正在创建一个应用程序使用离子版本4使用角形6!我需要获得定位设备,所以我使用了屏幕定位插件从Ionic 4文档:[https://beta.ionicframework.com/docs/native/screen-orientation]
但是,当我安装插件时,我收到了如下警告:
.8.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/ng-toolkit@1.0.8 requires a peer of @angular-devkit/build-angular@~0.8.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/ng-toolkit@1.0.8 requires a peer of @angular-devkit/core@~0.8.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/ng-toolkit@1.0.8 requires a peer of @angular-devkit/schematics@~0.8.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/schematics-angular@1.0.6 requires a peer of @angular-devkit/core@~0.8.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic/schematics-angular@1.0.6 requires a peer of @angular-devkit/schematics@~0.8.0-rc.1 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/screen-orientation@4.12.2 requires a peer of @ionic-native/core@^4.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ionic-native/screen-orientation@4.12.2 requires a peer of rxjs@^5.5.11 but none is installed. You must install peer dependencies yourself.
+ @ionic-native/screen-orientation@4.12.2
added 1 package in 8.608s现在,当我试图导入这样一个页面时:
编译失败。 未找到./node_modules/@ionic-native/screen-orientation/index.js模块:错误:无法解析'/Users/karthikcp/Documents/IONIC/testbake/node_modules/@ionic-native/screen-orientation‘中的“rxjs/可观”
我怎么能解决这个问题?
信息:
离子:
离子(离子CLI):4.1.2 (/usr/local/lib/node_node/ ionic )
离子框架:@离子型/角形4.0.0-beta.7
@角-devkit/核心: 0.7.5
@angular/示意图: 0.7.5
@角/cli: 6.1.5
@离子型/ng-工具包: 1.0.8
@离子/原理图-角度: 1.0.6
科多瓦:
cordova (Cordova CLI):7.1.0
科多瓦平台:无
科多瓦插件:没有白色插件(2个插件总数)
系统:
监督办-部署: 1.9.2
(/Users/karthikcp/.nvm/versions/node/v8.11.3/bin/node):v8.11.3 NodeJS
国家预防机制: 5.6.0
OS : macOS高塞拉
Xcode : Xcode 9.4.1构建9F2000版本
## Update
I reinstalled the plugin as : `npm install --save @ionic-native/screen-orientation@5.0.0-beta.15`
Now I am getting this error :
> ERROR in src/app/pages/test/test.page.ts(14,42): error TS2304: Cannot find name 'ScreenOrientation'.
>
Dependencies:
```javascript“依赖关系”:{
"@angular/common": "~6.1.1","@angular/core": "~6.1.1","@angular/forms": "~6.1.1","@angular/http": "~6.1.1","@angular/platform-browser": "~6.1.1","@angular/platform-browser-dynamic": "~6.1.1","@angular/router": "~6.1.1","@ionic-native/core": "5.0.0-beta.15","@ionic-native/screen-orientation": "^5.0.0-beta.15","@ionic-native/splash-screen": "5.0.0-beta.15","@ionic-native/status-bar": "5.0.0-beta.15","@ionic/angular": "4.0.0-beta.7","cordova-plugin-screen-orientation": "^3.0.1","core-js": "^2.5.3","rxjs": "6.2.2","zone.js": "^0.8.26"},
发布于 2019-02-12 06:55:14
我只会得到这个错误,如果我像这样导入:
import { ScreenOrientation } from '@ionic-native/screen-orientation';
但是,如果我将/ngx添加到@ionic-native/screen-orientation中,它将不会显示无法找到名称错误。但在我看来
NullInjectorError: No Provider for ScreenOrientation!如果您添加了/ngx,也许这份工作是想要的。
发布于 2020-06-08 16:26:19
这对我有用。在page.module中,导入依赖项:
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';并向该模块提供:
providers: [
ScreenOrientation,
...]小心,如果没有从外派进口中删除“ScreenOrientation”,它将需要一个类型记录界面。那是我的错。
https://stackoverflow.com/questions/52313426
复制相似问题