收到错误找不到模块“ crypto” [英] Getting error Cannot find module 'crypto'

查看:761
本文介绍了收到错误找不到模块“ crypto”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Angular 7中的节点加密模块进行非对称加密。
,并在下面的命令中用于导入加密模块

I am trying to use node Crypto module in Angular 7 for asymmetric encryption. and used below command to import the Crypto module

import * as crypto from 'crypto';

但仍然出现错误

`ERROR in src/app/log-in/log-in.component.ts(11,25): error TS2307: Cannot find module 'crypto'.`

请帮助我解决如何使用此库转换为Angular的错误。

Please help me to resolve the error that how to use this library into Angular.

预先感谢。

推荐答案

根据npm的作者,不再提供加密软件包,因为现在已内置到Node.js中。我建议寻找替代方案。我遇到了包含一些建议的Github要点: https://gist.github.com/jo/8619441

Per the author on npm , The crypto package is no longer available as it is now built in to Node.js. I would suggest looking for an alternative. I came across a Github Gist that contains some suggestions: https://gist.github.com/jo/8619441

请确保您选择的内容在浏览器中都可用。其中列出的某些选项仅在服务器端。

Make sure whatever you pick is useable in the browser. Some of the options listed there are server-side only.

这篇关于收到错误找不到模块“ crypto”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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