For my Angular 2 development using TypeScript and SystemJS, I needed to integrate crypto-js. Here is the configuration in my systemjs.config.js file:
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'crypto-js': 'npm:crypto-js/core.js',
'crypto-js/sha256': 'npm:crypto-js/sha256.js',
},
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'crypto-js': {
defaultExtension: 'js'
}
}
});
})(this);
In my service.ts file, I have included:
import 'crypto-js/sha256';
However, upon running the app, I encounter this error message:
http://localhost:3000/node_modules/crypto-js/core as "./core" from http://localhost:3000/node_modules/crypto-js/sha256.js
Any suggestions on how to resolve this issue?