【发布时间】:2016-07-20 11:12:12
【问题描述】:
我正在尝试在我的 angular2 项目中导入 crypto-js。
我关注了几个 SO 问题以及 angular-cli guide,但最后我仍然遇到错误 Cannot find module 'crypto-js'
我尝试了什么:
npm install crypto-js --save
和
typings install dt~crypto-js --global --save
然后我修改了文件angular-cli-build.js
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'zone.js/dist/**/*.+(js|js.map)',
'es6-shim/es6-shim.js',
'reflect-metadata/**/*.+(ts|js|js.map)',
'rxjs/**/*.+(js|js.map)',
'@angular/**/*.+(js|js.map)',
'crypto-js/**/*.+(js|js.map)'
]
});
};
和文件 src/system-config.ts
const map: any = {
'crypto-js': 'vendor/crypto-js'
};
/** User packages configuration. */
const packages: any = {
'crypto-js': {
format: 'cjs'
}
};
使用后
import * as CryptoJS from 'crypto-js';
我的错误仍然存在。我错过了什么吗?
谢谢
【问题讨论】: