user7479651
user7479651

Reputation: 759

Angular - How to correctly import md5 hash in Angular 2 typescript file?

I tried to use md5 hash for hashing user password in Angular 2, but for some reason when I run my application Md5 module is not recognized. enter image description here

I have also imported it in typescript file like this: import { Md5 } from 'ts-md5/dist/md5';

For me it's weird that Md5 is recognized in Visual Studio, but in Google Chrome I get error as you can see on picture. So my question is where is the mistake and how to fix it?

Upvotes: 1

Views: 2591

Answers (1)

joshsisley
joshsisley

Reputation: 310

If you are using systemJS (systemjs.config) then in that file you will need to include:

map:   {
          'ts-md5': 'node_modules/ts-md5',
       }
packages: {
          'ts-md5': {main: '/md5.js'},                
       }

Look for both 'map' and 'packages' inside of systemjs.config and then include 'ts-md5' in them. This will tell the app where to look for those files.

Also make sure that you have installed it first using npm install ts-md5 --save

Upvotes: 1

Related Questions