function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Goran K.Goran K. 

LWC static resource Error

Keep getting following error when I try to call static library for reading QR codes.
TypeError: a.default is not a function
    at v._tick (eval at t (aura_prod.js:1:1), <anonymous>:3:1996)
    at eval (eval at t (aura_prod.js:1:1), <anonymous>:3:2384)
The code is based on following article. 

https://eltoroit.medium.com/etqr-code-scanner-47ef5ea67d90

Has anyone experince similiar errors? Wonder if its the way of calling the library or something with the settings. 

Best Answer chosen by Goran K.
Goran K.Goran K.

If anybody have the same problem. You need to load the scripts before using them. Since every example I saw was not using scripts loading I totally missed that step.
 

To illustrate:

import { loadScript } from 'lightning/platformResourceLoader';
import jsQrScript from '@salesforce/resourceUrl/jsQR';

export default class JSqrcodeScan extends LightningElement {

	jsQR = jsQrScript;

		
	renderedCallback() {		
		loadScript(this, this.jsQR);
	}
}