2017-10-04 144 views
1

當我簡單的角度CLI應用程序添加一個依賴角找不到模塊「淨」

import {Socket} from 'net'; 

我得到運行時「納克開始」

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

是不是一個nodejs模塊?我認爲你不能在角度上使用它 –

+0

這個nodejs模塊 –

+0

只是用'Socketio'建立一個'nodejs服務器'並用你的角度應用程序與那個服務器通信https://medium.com/@REPTILEHAUS/angular-2-and- socket-io-chat-app-f56afb9ceeb2 https://github.com/jussikinnula/angular-socket-io-chat – Kuncevic

回答

2

您正嘗試導入一個節點錯誤模塊 - net,但它在瀏覽器中不可用。您需要爲您的客戶端提供一個套接字,例如socket.io但這當然取決於你想達到什麼。

+0

謝謝。我想從角度使用應用程序geth的ipc連接。 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)); –