[英]How do I import node crypto into my Angular 11 components?
I'm trying to implement a blockchain system in my angular application.我正在尝试在我的 angular 应用程序中实现区块链系统。 And I've created a typescript file with the class implementation and crypto import statement.
我创建了一个 typescript 文件,其中包含 class 实现和加密导入语句。
import * as crypto from 'crypto';
class Blockchain {//blockchain code here}
However when I import this class into my angular components.但是,当我将此 class 导入我的 angular 组件时。 I get this compile-time error 'Module not found: Error: Can't resolve 'crypto' in '...'';
我收到此编译时错误“找不到模块:错误:无法解析“...”中的“加密”;
I'm using Angular 12 node v16.3.0 typescript v4.1.5我正在使用 Angular 12 节点 v16.3.0 typescript v4.1.5
Thank you in advance先感谢您
Edit:编辑:
Usage of default crypto
from Node.js:使用来自 Node.js 的默认
crypto
:
const crypto = require('crypto');
Demo at StackBlitz . StackBlitz上的演示。
Official documentation: https://nodejs.org/api/crypto.html官方文档: https://nodejs.org/api/crypto.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.