Might be duplicate of Ref : Angular2 - Angular-CLI installing lodash - Cannot find module but didn't work for me
Followed https://github.com/angular/angular-cli/wiki/3rd-party-libs to import ts-md using https://www.npmjs.com/package/ts-md5
Imported ts-md5 using npm install ts-md5 --save on node_modules. My configuration in my angular-cli setup is
package.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 });
};
On ng build i could find md5 file imported inside vendor/ts-md5/dist/md5.js
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'
}
};
Included import * as md5 from 'md5' on my companent to import ts-md5.
On ng build i get 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
Any help on this would be great.