Getting error Cannot find module 'crypto'

泪湿孤枕 提交于 2020-02-03 02:22:29

问题


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';

but still I am getting error that is

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

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

Thanks in Advance.


回答1:


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.




回答2:


Make sure that you install 'crypto' module from npm

use: npm i crypto to install this module.

for more information please visit here.

If this is still not working then you have to check for alternative module because this module is dedicated you can check this



来源:https://stackoverflow.com/questions/54555730/getting-error-cannot-find-module-crypto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!