在WebPack构建环境中如何在Angular 2和TypeScript中使用CryptoJS? [英] How to use CryptoJS with Angular 2 and TypeScript in WebPack build environment?

查看:209
本文介绍了在WebPack构建环境中如何在Angular 2和TypeScript中使用CryptoJS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于将CryptoJS库与Angular 2一起使用存在很多问题,但大多数假设使用SystemJS,而所有这些似乎与当前版本的TypeScript都已过时。任何人都可以给出有关如何将Angular 2和TypeScript与CryptoJS库一起使用的简单明了的说明。

There are a whole bunch of questions around using the CryptoJS library with Angular 2 but most assume use of SystemJS and all seem out of date with the current version of TypeScript. Can anybody give clear, simple instructions on how to use the CryptoJS library with Angular 2 and TypeScript.

我已经使用 npm install crypto安装了CryptoJS。 -js

我尝试了推荐的输入方式i nstall crypto.js-环境--save ,但这只是警告--ambient被弃用并改用--global。

I've tried the recommended typings install crypto.js --ambient --save but this simply gives a warning about --ambient being deprecated and to use --global instead.

我改用了--global,但是

I've used --global instead but that then gives an error saying no typings were available!

向WebPack,NodeJS和TypeScript的新手提供的任何建议将不胜感激。我在node_modules文件夹下安装了CryptoJS库,但是任何明智的尝试导入 CryptoJS的尝试均因未找到模块而失败。

Any advice to someone new to WebPack, NodeJS AND TypeScript would be appreciated. I have the CryptoJS library installed under node_modules folder but any "sensible" attempts to "import" CryptoJS fail with "Module not found".

推荐答案

typings install dt~crypto-js --global --save

说明:

  • --global CryptoJS is global module
  • dt~ The typings are inside DT repository: https://github.com/DefinitelyTyped/DefinitelyTyped
  • --save Because you want it to be stored inside typings.json, don't you?

这篇关于在WebPack构建环境中如何在Angular 2和TypeScript中使用CryptoJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆