ereza
March 21, 2017, 10:14pm
1
Hi, I get following error, may somebody advice me how to solve this.
Error in ./TabsPage class TabsPage - caused by: No provider for BluetoothSerial!
StackTrace:
Error: DI Error
at v (http://localhost:8100/build/polyfills.js:3:4864 )
at NoProviderError.BaseError [as constructor] (http://localhost:8100/build/main.js:37044:27 )
at NoProviderError.AbstractProviderError [as constructor] (http://localhost:8100/build/main.js:77925:16 )
at new NoProviderError (http://localhost:8100/build/main.js:77987:16 )
My Code:
import { Component } from ‘@angular /core’;
import { NavController } from ‘ionic-angular’;
import { BluetoothSerial } from ‘@ionic-native /bluetooth-serial’;
@Component ({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
constructor(public navCtrl: NavController, private bluetoothSerial: BluetoothSerial) {
//console.log (bluetoothSerial.isEnabled());
//console.log (bluetoothSerial.list());
}
}
Ionic Framework: 2.2.0
Ionic Native: 2.8.1
Ionic App Scripts: 1.1.4
Angular Core: 2.4.8
Angular Compiler CLI: 2.4.8
Node: 4.2.6
OS Platform: Linux 4.8
Navigator Platform: Linux x86_64
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36
plmetz
March 22, 2017, 12:59am
2
Did you first install the Bluetooth Serial native component?
$ ionic plugin add cordova-plugin-bluetooth-serial
$ npm install --save @ionic-native/bluetooth-serial
ereza
March 22, 2017, 5:29am
3
Yes, I hav installed the native component. However, npm prints warnings at installing the serial comp., I dont know if this causes the problem.
npm install --save @ionic-native /bluetooth-serial
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.1.1
This is caused by the fact that you are using ionic-native 3 syntax on 2.8. Either upgrade to 3.1.0 or change your import to be from ‘ionic-native’.
ereza
March 22, 2017, 5:46am
5
Ok, how do I upgrade to ionic-native 3? I changed the ionic-nativ version number in package.json, but npm prints out that the most recent valid target version is 2.9.
see:
npm ERR! notarget No compatible version found: ionic-native@3.1.0
npm ERR! notarget Valid install targets:
npm ERR! notarget 2.9.0, 2.8.1, 2.8.0, 2.7.0, 2.6.0, …
PS.:
Even if I change the import to “ionic-nativ”, I get the error.
“import {BluetoothSerial} from “ionic-native”;”
ereza
March 22, 2017, 6:18am
6
Ok, I removed ionic/native 2.8.1 and installed 3.1.1. Still same issue!
Ionic Framework: 2.2.0
Ionic App Scripts: 1.1.4
Angular Core: 2.4.8
Angular Compiler CLI: 2.4.8
Node: 6.10.1
OS Platform: Linux 4.8
Navigator Platform: Linux x86_64
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/56.0.2924.76 Chrome/56.0.2924.76 Safari/537.36
Have you completely erased node_modules
, cleared the npm cache, and run npm install
again?
ereza
March 22, 2017, 6:34am
8
Ok, Bros! I solved the problem.
I didn’t declared the bluetooth provider in my app modules.
see http://ionicframework.com/docs/v2/native/#Add_Plugins_to_Your_App_Module
thx and best regards!