在导入供应商Npm文件ts-md5上找不到模块'md5'



可能是Ref: Angular2 - Angular-CLI安装lodash -找不到模块但不适合我的重复

按照https://github.com/angular/angular-cli/wiki/3rd-party-libs使用https://www.npmjs.com/package/ts-md5

导入ts-md

使用npm install ts-md5——save在node_modules上导入ts-md5。我在angular-cli设置中的配置是

包。json:

"devDependencies": {
  ......
  "ts-md5": "^1.2.0"
}

anular-cli-build config:

 var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
 var mergeTree = require('broccoli-merge-trees');
 module.exports = function(defaults) {
 let appTree = new Angular2App(defaults, {
 sassCompiler: {
  cacheExclude: [//_[^/]+$/]
 },
 vendorNpmFiles: [
   ....
  'ts-md5/dist/md5.js'
 ]
 })
 return mergeTree([appTree], { overwrite: true });
 };

在ng构建中,我可以在vendor/ts-md5/dist/md5.js中找到导入的md5文件

system-config。ts:

const map: any = {
  'moment' : 'vendor/moment/moment.js',
  'ng2-bootstrap' : 'vendor/ng2-bootstrap',
  '@angular2-material': 'vendor/@angular2-material',
  'd3' : 'vendor/d3',
  'md5': 'vendor/ts-md5/dist/md5.js'
};
/** User packages configuration. */
const packages: any = {
  'moment' : {
    format: 'cjs'
  },
  'ng2-bootstrap' : {   
    defaultExtension: 'js'
  },
  'd3' : {
    format: 'cjs',
    defaultExtension: 'js',
    main: 'd3.min.js'
  },
  'md5': {
    format: 'cjs',
    defaultExtension: 'js',
    main: 'md5.js'
  }
};

包含import * as md5 from 'md5'在我的公司导入ts-md5

在ng构建中我得到Cannot find module 'md5'

Error: Typescript found the following errors:
GitRepo/app-web/tmp/broccoli_type_script_compiler-input_base_path-zurkjkU9.tmp/0/src/app/shared/gravatar/gravatar.component.ts (3, 22): Cannot find module 'md5'.
at BroccoliTypeScriptCompiler._doIncrementalBuild (/GitRepo/app-web/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:120:19)
at BroccoliTypeScriptCompiler.build (/GitRepo/app-web/node_modules/angular-cli/lib/broccoli/broccoli-typescript.js:43:10)
at /GitRepo/app-web/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:152:21

如果有任何帮助就太好了。

安装此模块

npm install ts-md5 --save

将此添加到您的typing .d.ts

declare module 'md5' { var exportAs:any; export = exportAs; }

相关内容

  • 没有找到相关文章

最新更新