【问题标题】:Angular cannot find module 'net'Angular 找不到模块“net”
【发布时间】:2017-10-04 09:16:47
【问题描述】:

当我在简单的 Angular CLI 应用程序中添加依赖项时

import {Socket} from 'net';

运行“ng start”时出现错误

ERROR in C:/IdeaProjects/GethIPC/src/app/app.component.ts (5,20): Cannot find module 'net'

【问题讨论】:

标签: javascript node.js angular typescript angular-cli


【解决方案1】:

您正在尝试导入节点模块 - net,但它在浏览器中不可用。您需要为您的客户提供一个套接字,例如socket.io 但这当然取决于您想要实现的目标。

【讨论】:

  • 谢谢。我想从角度使用 ipc 连接和应用程序 geth。 var net = require('net'); var web3 = new Web3('/Users/myuser/Library/Ethereum/geth.ipc', net); var web3 = new Web3(new Web3.providers.IpcProvider('/Users/myuser/Library/Ethereum/geth.ipc', net));
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-08
  • 2017-04-29
  • 2017-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多