Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Cannot find module fingerprintjs2' error when importing the library in Angular project

I am trying to use fingerprint2.js in Angular project.

First, I installed the library via:

npm install fingerprintjs2

Added:

./node_modules/fingerprintjs2/fingerprint2.js in angular.json file in scripts section.

Imported the library in app.module.ts or myservice.ts as:

import * as Fingerprint2 from 'fingerprintjs2'

After importing, I am getting Cannot find module 'fingerprintjs2' error.

Is there any solution? What is it that I am doing wrong?

like image 862
Marium Malik Avatar asked Mar 17 '26 22:03

Marium Malik


1 Answers

I was having the same problem with fingerprintjs2 after I upgraded to 2.0.4. Going back to version 2.0.3 fixed it. They changed something in the latest release around module.exports: https://github.com/Valve/fingerprintjs2/commit/1e07962c04bb473af6c024e562b60f11581d6a99

like image 149
Dan Avatar answered Mar 20 '26 12:03

Dan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!