I have gone through countless tutorials on this particular issue, but unfortunately, I have not yet found a solution. Let me provide some context first. I am working on an Angular 2 application and I need to incorporate this JS library for encryption: https://github.com/travist/jsencrypt
Initially, I added the jsencrypt node module using the command: npm install --save jsencrypt. The installation was successful, and I could locate the jsencrypt module in my node_modules folder.
Following some guides, I created a src/typings.d.ts file with the line: declare module 'jsencrypt'; as suggested.
Subsequently, in my components.ts file, I imported it by adding this line: import * as JSEncrypt from 'jsencrypt';
I also attempted to include < script src="/node_modules/jsencrypt/bin/jsencrypt.js">< /script>
in my .html file.
Within the initialization of my .component file, I tried to declare a basic JSEncrypt object: var decrypt = new JSEncrypt();
However, upon doing so, the console threw the following error: TypeError: Object is not a constructor (evaluating 'new WEBPACK_MODULE_4_jsencrypt()')
This led me to believe that the jsencrypt module was not being recognized correctly.
Since I am relatively new to Angular and have only been working with it for a few days, I am still learning all the terminology and fundamental concepts associated with the structural elements of an Angular application. Any guidance or assistance would be highly appreciated.
I utilized this tutorial as a starting reference point: