I have looked through all the tutorials revolving around this issue, and havn't been able to find a solution. Some background first. I have a Angular 2 app and I need to use this JS library for encryption: https://github.com/travist/jsencrypt
First, I installed the jsencrypt node module with the line: npm install --save jsencrypt. This worked, and the jsencrypt module could be found in my node_modules folder.
Some tutorials told me to create a src/typings.d.ts file then add in the following line: declare module 'jsencrypt';
Then, in my comonents.ts file I import it with this line: import * as JSEncrypt from 'jsencrypt';
I also tried adding < script src="/node_modules/jsencrypt/bin/jsencrypt.js">< /script>
into my .html file.
In the init of my .component file, I try declaring a simple JSEncrypt object: var decrypt = new JSEncrypt();
And the console displays this error: TypeError: Object is not a constructor (evaluating 'new WEBPACK_IMPORTED_MODULE_4_jsencrypt()')
So I'm assuming it does not recognize the jsencrypt module.
I have only been working with Angular for a couple of days, so I'm very new to all the terminology and basic understanding of the structural components of an Angular application. Any help is greatly appreciated.
Used this tutorial as a starting point: https://hackernoon.com/how-to-use-javascript-libraries-in-angular-2-apps-ff274ba601af