1

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?

6
  • are you using systemJS? Commented Jun 5, 2017 at 15:58
  • you mean systemjs.config.js? I'm new to Angular 2 and I don't fully understand what is systemJS Commented Jun 5, 2017 at 16:01
  • yeah systemjs.config.js Commented Jun 5, 2017 at 16:05
  • yes, I'm using it. Do I have to put something related to md5 in systemjs? Commented Jun 5, 2017 at 16:06
  • yeah, I posted an answer below that should work for you. Commented Jun 5, 2017 at 16:11

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

6 Comments

I'll try it now. Hopefully my problem will be solved :). If this works your answer will be accepted.
I get the same error. This doesn't solve my problem.
hmm, unfortunately without seeing more of the code it is hard to say what the issue is. But basically that error means it can't find ts-md5 package at all. Are you using node_modules or did you just copy the files into your project?
I'm using node_modules and ts-md5 is stored in node_modules/ts-md5/dist/md5. I have installed it using npm.
oh actually I think I know the issue. Inside of the 'map' from above try changing the path to: node_modules/ts-md5/dist
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.