Skip to content

Runtime error when using require("net"); Mac OS/xcode #39

Closed

Description

@n0n0n0

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?

Activity

  1. fealebenpae commented on Apr 17, 2015

    @fealebenpae
    Contributor

    Hi @n0n0n0,

    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.

  2. n0n0n0 commented on Apr 17, 2015

    @n0n0n0
    Author

    As I said statement require("net") palced in main-page.js from standart demo app (by tns create app) so i think it called after require("application")

    I thought net module is built-in in node? If NS not supported it how i can make tcp connect to some host and port?

  3. n0n0n0 commented on Apr 17, 2015

    @n0n0n0
    Author

    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'.

  4. n0n0n0 commented on Apr 17, 2015

    @n0n0n0
    Author

    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?"

  5. fealebenpae commented on Apr 17, 2015

    @fealebenpae
    Contributor

    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 @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.

  6. n0n0n0 commented on Apr 17, 2015

    @n0n0n0
    Author

    Ok, thank you @fealebenpae.

  7. lock commented on Aug 31, 2019

    @lock

    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.

  8. locked and limited conversation to collaborators on Aug 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions