[英]Use 'net' Node.js module in ReactNative
我想在 React Native 移動應用程序中使用net Node.js 模塊。
我首先創建了一個簡單的 node.js 腳本來使用以下代碼測試客戶端/服務器連接。
const net = require('net');
const client = new net.Socket();
client.connect({ port: 59090, host: process.argv[2] });
client.on('data', (data) => {
console.log(data.toString('utf-8'));
});
一切正常,但是當我從 ReactNative 應用程序調用此腳本時,出現以下錯誤:
Unable to resolve module `net` from `Client.js`: net could not be found within the project.
為什么我不能在本機應用程序中使用 node.js 庫? 有沒有其他選擇
我認為您正在尋找react-native-tcp-socket 。 這是因為你不能從 React Native 使用 node Net。 在我提供的鏈接上閱讀自述文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.