Reputation: 15
So basically I import:
import { Md5 } from 'ts-md5/dist/md5';
But it says that:
Module has no exported member Md5?
But it works fine, problem is that it is giving me an error while compiling.
I changed it to lowercase md5 like:
import { md5 } from 'ts-md5/dist/md5';
But now my function doesnt work:
hashIt(email: string){
this.hashString = md5.hashStr(email);
console.log(this.hashString);
}
It says:
Property 'hashStr' does not exist on type '(string : any) => string'.
Upvotes: 1
Views: 683
Reputation: 2326
Make sure it is installed npm install --save ts-md5
.
Import it directly in the component where you have to use it:
import { Component } from '@angular/core';
import {Md5} from 'ts-md5/dist/md5';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
name = 'Angular';
md5 = new Md5();
ngOnInit(){
console.log(this.md5.appendStr('hello').end());
}
}
Working StackBlitz, if still not working, try npm uninstall ts-md5
then npm install --save ts-md5
Upvotes: 1