This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Closed

Noob NodeJS questions.

nklerknklerk Member
Hi guys,

I am trying to write my own homey app. and i need some pushes in the right direction. I have programming knowledge but NodeJS is totaly new to me. and between the trees i can't see the Forrest. lol

For this i am stuck at the very beginning of my code. Including a module.
I cant get the inclusion to work.

I have downloaded the nodeJS module at https://github.com/nfarina/homebridge
and placed the files in my app path: nl.nielsdeklerk.homebridge/node_modules/homebridge/

the start of my app.js looks like:
"use strict";
var http = require('http');
var Accessory, Service, Characteristic, UUIDGen;
var homebridge = require('homebridge');   // <- This line fails

Debug output:
-------------------------------------------------
Error: Cannot find module 'homebridge'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/app.js:6:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)

--- INFO: nl.nielsdeklerk.homebridge has been killed ---

What am i overseeing. looks like it's not a module. but when i look at the code of others i dont know where to look for.



Comments

  • jordenjorden Member
    edited May 2016
    Go commandline, go to the folder nl.nielsdeklerk.homebridge

    Create a directory node_modules (in OSX: mkdir node_modules, Windows should be somewhat similar)
    Type in:
    git clone https://github.com/nfarina/homebridge

    That should do it. Ofcourse, first you'll have to install git if you don't have it.
  • You should install the module via npm. Open a commandline window and execute:

    npm install homebridge --prefix "C:/users/path_to_your_app_nl.nielsdeklerk/"

    This should automatically create a folder 'node_modules' in your root folder and will also install all the dependencies of the homebridge node module
  • jordenjorden Member
    I actually also do npm install homebridge. Had a brainfart when I typed the git clone thing. 
  • nklerknklerk Member
    Thanks for all the the help. I am now installing all the building dependancies: git, VS, Windows sdk, python. :-)
  • nklerknklerk Member
    Ok I gave up :-( To much binaries needed that i'm having issues getting to work. let alone having this working on the homey. Many thanks for the push in the right direction.
  • eelco2keelco2k Member
    edited December 2016
    I've tried almost the same, but because of some node_modules which are required for a specific os distribution it was not possible for me to get homebridge running on homey itself. i'm getting this error:

    /node_modules/mdns/build/Release/dns_sd_bindings.node: invalid ELF header

    Because I use a Mac os x to compile this module. it is compiled for Mac os x and not for the Homey os distribution.

    Hopefully someone can give me some direction in what kind of OS i need to compile so that these modules will work for Homey. 
  • Already found the OS which Homey runs on. Raspbian. I tried to use this docker image to emulate ARM. 
    https://hub.docker.com/r/jsurf/rpi-raspbian/

    But i'm getting some node specific error regarding the os.networkInterface(). So i think i'm not able to compile for ARM cpu.
This discussion has been closed.