Unknown Coder
Unknown Coder

Reputation: 1740

export 'JSEncrypt' was not found in 'jsencrypt' in Angular

I'm using Angular 9 App. installed jsencrypt using npm

npm install jsencrypt

And using this in one of my helper classes as below:

import { JSEncrypt } from 'jsencrypt';
en: any;
export class AuthHelperService {
  constructor(private http: HttpService) {
    this.en = new JSEncrypt();
  }
}

Getting error at following line. How to use this plugin in Angular properly?

import { JSEncrypt } from 'jsencrypt';

Terminal Log:

Error: src/app/core/services/auth-helper.service.ts:2:10 - error TS2614: Module '"../../../../node_modules/jsencrypt/lib"' has no exported member 'JSEncrypt'. Did you mean to use 'import JSEncrypt from "../../../../node_modules/jsencrypt/lib"' instead?

2 import { JSEncrypt } from 'jsencrypt';

Upvotes: 0

Views: 1659

Answers (1)

Andrei
Andrei

Reputation: 12206

the correct way to import JSEncrypt would look like

import JSEncrypt from 'jsencrypt';

the way you are trying to import that object is just wrong

Upvotes: 3

Related Questions