问题描述
关于将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
说明:
-
-全局
CryptoJS是全局模块 -
dt〜
键入内容位于DT存储库中: -
-保存
因为您希望将其存储在类型中.json
,不是吗?
--global
CryptoJS is global moduledt~
The typings are inside DT repository: https://github.com/DefinitelyTyped/DefinitelyTyped--save
Because you want it to be stored insidetypings.json
, don't you?
这篇关于在WebPack构建环境中如何在Angular 2和TypeScript中使用CryptoJS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!