It seems that an error has occurred: DOMException was thrown because the attempt to run 'importScripts' on 'WorkerGlobalScope' has failed. The script located at 'http://localhost:4200/BlinkCardWasmSDK.js' was unable to load properly

Recently, I attempted to integrate this credit card reader into my Angular application. Despite carefully following all the installation steps and obtaining a valid license key, I encountered the following error:

Error during the initialization of the SDK! DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:4200/BlinkCardWasmSDK.js' failed to load.

In adherence to the documentation, I've implemented the following method in my component:

 scanCard() {
    if ( BlinkCardSDK.isBrowserSupported() ) {
      const loadSettings = new BlinkCardSDK.WasmSDKLoadSettings( 'sRwAAAYJbG9jYA==' );

      BlinkCardSDK.loadWasmModule( loadSettings ).then
      (
        ( wasmSDK: BlinkCardSDK.WasmSDK ) => {
          // Successfully initialized SDK, save wasmSDK for future use
          BlinkCardSDK.createBlinkCardRecognizer( wasmSDK ).then(recognizer => {
            BlinkCardSDK.createRecognizerRunner( wasmSDK, [ recognizer ], true ).then(recognizerRunner => {
              const cameraFeed = document.getElementById( 'camera-feed' ) as HTMLVideoElement;
              BlinkIDSDK.VideoRecognizer.createVideoRecognizerFromCameraStream(cameraFeed, recognizerRunner)
                .then(videoRecognizer => {
                  videoRecognizer.recognize().then(processResult => {
                    if ( processResult !== BlinkIDSDK.RecognizerResultState.Empty ) {
                     recognizer.getResult().then(recognitionResult => {
                       console.log( recognitionResult );

                     });
                    } else {
                      console.log( 'Recognition was not successful!' );
                    }
                    console.log(processResult);
                  });

              });
            });

          });
        },
        ( error: any ) => {
          // Error occurred during SDK initialization
          console.log( 'Error during SDK initialization!', error );
        });
    } else {
      console.log( 'This browser is not supported by the SDK!' );
    }
  }

In the HTML file, you will find:

<body>
<div id="screen-initial">
  <h1 id="msg">Loading...</h1>
  <progress id="load-progress" value="0" max="100"></progress>
</div>

<div id="screen-start" class="hidden">
  <a href="#" id="start-scan">Start scan</a>
</div>

<div id="screen-scanning" class="hidden">
  <video id="camera-feed" playsinline></video>
  <!-- Recognition events will be drawn here. -->
  <canvas id="camera-feedback"></canvas>
  <p id="camera-guides">Point the camera towards Payment cards.</p>
</div>
</body>

Although I have included the BlinkCardWasmSDK.js in /src/assets/BlinkCardWasmSDK.js, the error persists. Could there be a missing reference that I overlooked? Any assistance would be greatly appreciated.

Answer №1

Ongoing connectivity issues are hindering BlinkID from locating the necessary resources it needs for operation. To resolve this issue, you must direct BlinkID to the specific location of these resources within your angular.json configuration file (Angular workspace configuration docs) under architect, build, options, and assets array as demonstrated below:

          "assets": [
              {
                "glob": "**/*",
                "input": "node_modules/@microblink/blinkid-in-browser-sdk/resources",
                "output": "/"
              }
            ]

It is not necessary to physically relocate the BlinkID resources to your assets folder; rather, simply ensure that it is correctly specified to reside within the node_modules directory. Feel free to reach out if further assistance is needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular is programmed to detect any alterations

Upon detecting changes, the NgOnChanges function triggers an infinite service call to update the table, a situation that currently perplexes me. Any assistance on this matter would be greatly appreciated. Many thanks. The TableMultiSortComponent functions ...

Observing with starting value

When using an observable, I am trying to filter and display a list. The input event is only fired when the user starts typing, so initially the list is not displayed. How can I set a default value for the observable this.filterLocation$ until the input eve ...

Leverage HighCharts on numerous occasions

Hello there, I'm curious about utilizing the Highcharts library in my Angular application. I have 3 tabs (sale / rental / rental & sale), each with 3 identical diagrams that display different data from my API. Currently, my setup only works on t ...

Encountering a problem while setting up a Node JS project with npm/npx using vite/react js, resulting in the error message: "node:internal/modules/cjs/loader:120

Currently, I have Node.js version v22.0.0 installed on my system. I am working on creating a new React JS project using Vite technology. However, when I try to initiate the project, I encounter an error in the terminal. npm create vite@latest node:interna ...

What causes interface to generate TS2345 error, while type does not?

In the code below: type FooType = { foo: string } function fooType(a: FooType & Partial<Record<string, string>>) { } function barType(a: FooType) { fooType(a) } interface FooInterface { foo: string } function fooInterface(a: FooInt ...

Verify the type without making any assumptions about the checked type

Take a look at this type definition: interface ISmth<T> { id: number; data: T; } Now, I am interested in creating an array that contains elements of this type: var a = [{ id: 1, data: [], }, { id: 2, data: 4, }, { id: 3, data: "abc ...

Testing Playwright - accessing variables from the .env file

I am currently working on a Playwright test script in TypeScript and I'm looking for a way to leverage variables from my .env file within the test. Does anyone know how this can be accomplished? ...

Angular Material: angular 4 alternative for detecting screen size greater than medium using $mdMedia('gt-md') function

Currently, I am working on integrating a sidenav into my web application with a focus on making it responsive. To accomplish this, I am utilizing Angular Material2 and Angular 4. <md-sidenav #sidenav layout="column" class="md-sidenav-left" md-component- ...

Dynamic routing with ngIf in Angular 2's router system

Is there a way to use *ngIf with dynamic router in Angular? Let's say I have a top navigation component with a back button, and I only want the back button to be visible on the route 'item/:id'. I tried using *ngIf="router.url == '/ite ...

Updating dependencies of dependencies in npm: A step-by-step guide

I'm puzzled by the fact that I can't seem to find a solution to this seemingly easy question. It's surprising that even running npm update doesn't resolve the issue. While I can't post my entire dependency tree here, I'll do ...

Ways to display the ping of a game server on your screen

Is there a way to display the game server's ping on the screen like in the example below? this.tfEnter.text = ShowPing + " ms"; Sometimes the code snippets provided in examples may not function properly. Channel List Image: https://i.stack ...

Can you explain the significance of the term "running npm packages globally" in this particular scenario?

It seems to me that when I run npm install, the package is added to the project's dependencies by default. However, using npm install -g adds the package to the global scope. Can someone help clarify what the npm documentation is referring to here? ...

I'm having trouble retrieving the object value from a different function within my Typescript and Express application

Currently I am experimenting with utilizing typescript alongside express for my application development. I have created a function that I intend to utilize in various sections of my codebase. Upon invoking the function, I am able to observe the values thro ...

Validating mixed types and generics within an array using Typescript's type checking

I am currently working with a setup that involves defining interfaces for animals and their noises, along with classes for specific animals like dogs and cats. I am also storing these animals in an array named pets. interface Animal<T> { name: stri ...

Exploring Custom Scrolling Effects in Angular 2

Have you ever heard of react-router-scroll in React? It allows React app pages to scroll smoothly like a regular website. The feature scrolls to the top of each new page (route), while remembering the scroll position of previous pages. This means that when ...

A guide on transforming a Firebase Snapshot child into a personalized object in a React Native environment

I'm looking for a way to retrieve data from Firebase Realtime Database and display it in FlatList format. What is the most efficient method for extracting the child value and converting it into a custom object? For example: class CustomObject { ...

"Launching" conduit for Observable

Is there a way to attach two pipes to an HttpClient request in order to execute functions at the beginning and end of the request? I have discovered the "finalize" operator for executing a function when the request is finished, but I am looking for an equi ...

Node application running in Docker cannot establish connection with the Postgres database also running in Docker

I've experimented with various solutions, but none of them seem to work for me. Here's what I did: I set up a nodejs container and a postgres docker container. I used docker compose to configure both and a Dockerfile to build the nodejs/typescri ...

Using RegEx, npm nlf can be utilized to extract version numbers from the text

Recently, I've been exploring the amazing nlf package to compile a list of licenses. However, I'm looking to exclude the specific version numbers from the extensive list it generates. As someone who is still getting the hang of RegEx, I have co ...

Trouble with parsing JSON in NodeJs

I have a JSON file containing the names of people that are stored. Using the Node Manager's filesystem, I read the content from this file and attempt to convert the JSON to a string and then parse it into a JavaScript object. However, after parsing it ...