This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
对引用的方式进行修改
import md5 from "md5" ==> import * as md5 from "md5"
在测试TypeScript时,使用package.json 中的script 命令时,不能使用
import md5 from "md5"
而在添加了tsconfig.json
{
"compilerOptions": {
"target": "es6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"module": "es6", /* Specify what module code is generated. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
"strict": true, /* Enable all strict type-checking options. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"outDir": "./dist"
}
}
使用tsc进行build 时,又可以使用 import md5 from "md5",但是不能使用 import * from as md5 from "md5"