I\'ve installed md5
(also tried blueimp-md5
) package with corresponding typings like this:
nmp install --save md5 @types/md5
You don't need to specify the path inside the node_modules
, it should be:
import * as md5 from "md5";
The compiler will look for the actual module in the node_modules
, and will look for the definition files in node_modules/@types
.
There's a long doc page about it: Module Resolution
That's because of how the md5
module is exporting, as it does this:
declare function main(message: string | Buffer): string;
export = main;
This case is covered in the docs:
The export = syntax specifies a single object that is exported from the module. This can be a class, interface, namespace, function, or enum.
When importing a module using export =, TypeScript-specific import let = require("module") must be used to import the module.
In your case it should be:
import md5 = require("md5");
If you're targetting es6
then you need to do:
const md5 = require("md5");
(or let
or var
of course).