I imported import { BarcodeScanner } from ‘@ionic-native/barcode-scanner/ngx’; and I installed barcode scanner ngx. While it was scanning in another project, it does not work in a bigger project.
ERROR TypeError: Object(…) is not a function at BarcodeScanner.scan (index.js:31) at HomePage.webpackJsonp.31.HomePage.scanCode (home.ts:64) at Object.eval [as handleEvent] (HomePage.html:63) at handleEvent (core.js:13547) at callWithDebugContext (core.js:15056) at Object.debugHandleEvent [as handleEvent] (core.js:14643) at dispatchEvent (core.js:9962) at core.js:10587 at HTMLButtonElement. (platform-browser.js:2628) at t.invokeTask (polyfills.js:3)
here is my ionic info:
Ionic:
Ionic CLI : 5.2.3 (C:\Users\Dogaç\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.4
Cordova:
Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 8 other plugins)
Utility:
cordova-res : not installed
native-run : 0.2.8
System:
NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
npm : 6.9.0
OS : Windows 10
home.html content: <button ion-button full icon-left (click)=“scanCode()” expand=“full” size=“large” color=“dark”>
Scan barcode
home.ts
scanCode(){
this.BarcodeScanner.scan().then(data => {
// this is called when a barcode is found
this.scannedCode = data.text
console.log(this.scannedCode);
});
}