You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Runtime error when using require("net"); Mac OS/xcode #39
When I try use node module "net" in main-page.js like this var net = require("net");
I get runtime error. As I wrote in issues here I still cant run app with tns run ios --emulator but i can run it in xcode from xcodeproject file in platforms/ios. So I see this error only in debug mode in xcode (while app in emulator show me start screen with "NativeScreen" icon). In xcode debug screen with assembler-like view i see this: Thread 1: EXC_BAD_ACCESS (code=1, address=0xbbadveef)
When I delete statement 'var net = require("net");` app works fine.
So whats wrong here?
NativeScript doesn't ship a net module. Is it perhaps one you've added yourself? The output in the Xcode debugger window should hold more details to what the actual cause of the error is, please check that and paste it here so we can take a look.
I just found error in Xcode (i have old small monitor on mac). Here it is undefined:76:153: JS ERROR Error: Failed to find module 'net' relative to '/app/main-page.js'.
I have tried npm install net and npm install -g net but still dosent work, so I would convert my first question to "does NS support standart node.js modules (that install by npm install module?"
net is a built-in module in Node.js. NativeScript has its own set of built-in modules. We would like to eventually be fully node-compatible, as mentioned by @ligazhere, but we're not there yet.
Even though there isn't a cross-platform socket API right now, you can use native APIs such as CFStream on iOS or Socket on Android in your JavaScript code.
Activity
fealebenpae commentedon Apr 17, 2015
Hi @n0n0n0,
NativeScript doesn't ship a
netmodule. Is it perhaps one you've added yourself? The output in the Xcode debugger window should hold more details to what the actual cause of the error is, please check that and paste it here so we can take a look.n0n0n0 commentedon Apr 17, 2015
As I said statement
require("net")palced in main-page.js from standart demo app (bytns create app) so i think it called afterrequire("application")I thought
netmodule is built-in in node? If NS not supported it how i can make tcp connect to some host and port?n0n0n0 commentedon Apr 17, 2015
I just found error in Xcode (i have old small monitor on mac). Here it is
undefined:76:153: JS ERROR Error: Failed to find module 'net' relative to '/app/main-page.js'.n0n0n0 commentedon Apr 17, 2015
I have tried
npm install netandnpm install -g netbut still dosent work, so I would convert my first question to "does NS support standart node.js modules (that install bynpm install module?"fealebenpae commentedon Apr 17, 2015
netis a built-in module in Node.js. NativeScript has its own set of built-in modules. We would like to eventually be fully node-compatible, as mentioned by @ligaz here, but we're not there yet.Even though there isn't a cross-platform socket API right now, you can use native APIs such as CFStream on iOS or Socket on Android in your JavaScript code.
n0n0n0 commentedon Apr 17, 2015
Ok, thank you @fealebenpae.
lock commentedon Aug 31, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.