KevinVR / milights-bridge

An application for controlling your Milight lights using any device. Provides GUI and API.
Other
20 stars 3 forks source link

Error when running server.js #1

Open southchurchbob opened 7 years ago

southchurchbob commented 7 years ago

Hi there, I'm following the instructions, I think, fully, but when I issue the command "sudo node server.js" I get the following output, all the build to this point appears successful.

" Setting up EJS... Initialising Milight bridge connection (version v6) Checking for updates...

/home/pi/milights-bridge/server.js:477 .execSync('git rev-parse HEAD') ^ TypeError: Object # has no method 'execSync' at getLastCommitId (/home/pi/milights-bridge/server.js:477:4) at refreshUpdateCache (/home/pi/milights-bridge/server.js:492:14) at initIBox (/home/pi/milights-bridge/server.js:312:2) at Server. (/home/pi/milights-bridge/server.js:290:2) at Server.g (events.js:180:16) at Server.emit (events.js:92:17) at net.js:1055:10 at process._tickCallback (node.js:419:13) at Function.Module.runMain (module.js:499:11) at startup (node.js:119:16) at node.js:906:3 "

KevinVR commented 7 years ago

Hi!

I must have forgotten to add a package to the package.json. Or the issue could be that you have an older version globally installed.

Running the following command inside the /milights-bridge/ folder should solve the problem temporarily (until next commit):

sudo npm install child_process

If it doesn't work, try

sudo npm install -g child_process

Let me know if you have any other problems!

On the other hand I found a project with a similar issue, let me know if this solved it, otherwise I will implement a similar fix into this project as soon as possible.

mpartoglou commented 7 years ago

Hi KevinVR,

I noticed the same issue when trying to use the code - I am also running this on the RaspberryPi (which has OSMC as the default build) and am getting the same error as the other user.

I ran both version of the install child_process (as recommended above) - see below for output of both attempts.

Attempt 1: after running sudo npm install child_process osmc@osmc:~/milights-bridge$ sudo nodejs server.js Setting up EJS... Initialising Milight bridge connection (version v6) Checking for updates...

/home/osmc/milights-bridge/server.js:477 .execSync('git rev-parse HEAD') ^ TypeError: Object # has no method 'execSync' at getLastCommitId (/home/osmc/milights-bridge/server.js:477:4) at refreshUpdateCache (/home/osmc/milights-bridge/server.js:492:14) at initIBox (/home/osmc/milights-bridge/server.js:312:2) at Server. (/home/osmc/milights-bridge/server.js:290:2) at Server.g (events.js:180:16) at Server.emit (events.js:92:17) at net.js:1055:10 at process._tickCallback (node.js:419:13) at Function.Module.runMain (module.js:499:11) at startup (node.js:119:16) at node.js:906:3

Attempt 2 osmc@osmc:~/milights-bridge$ sudo npm install -g child_process child_process@1.0.2 /usr/local/lib/node_modules/child_process osmc@osmc:~/milights-bridge$ sudo nodejs server.js Setting up EJS... Initialising Milight bridge connection (version v6) Checking for updates...

/home/osmc/milights-bridge/server.js:477 .execSync('git rev-parse HEAD') ^ TypeError: Object # has no method 'execSync' at getLastCommitId (/home/osmc/milights-bridge/server.js:477:4) at refreshUpdateCache (/home/osmc/milights-bridge/server.js:492:14) at initIBox (/home/osmc/milights-bridge/server.js:312:2) at Server. (/home/osmc/milights-bridge/server.js:290:2) at Server.g (events.js:180:16) at Server.emit (events.js:92:17) at net.js:1055:10 at process._tickCallback (node.js:419:13) at Function.Module.runMain (module.js:499:11) at startup (node.js:119:16) at node.js:906:3 osmc@osmc:~/milights-bridge$

Hope this helps with your debugging, happy to test again on the next commit.

Lucas183 commented 6 years ago

Hi KevinVR,

thank you for the great work! Unfortunately, I've got the same issue. Is there any other solution than running the 2 commands? It didn't work for me :( .

KevinVR commented 6 years ago

Thanks for the information, I will see if I can reproduce the errors.

KevinVR commented 6 years ago

@mpartoglou @Lucas183 @southchurchbob Sorry for the delay, please make a fresh install, I have updated some things that should solve these problems :).

Let me know if it works!

Lucas183 commented 6 years ago

image Now it's a different error message. But still doesn't work for me :(

mwittig commented 6 years ago

I think the the problem is that you have "child_process" included as a dependency in package.json which is just a "security holding package on npmjs". My suggestion is that to remove that. As "child_process" is an API of the Node.JS base library there is no dependency entry for that.

@Lucas183, @mpartoglou EDIT: Which version of nodejs are you using? Supposedly, it is anything newer than v0.10?!

node --version

EDIT2: Make sure to uninstall "child_process" again!


sudo npm uninstall child_process
sudo npm uninstall -g child_process
KevinVR commented 6 years ago

@mwittig Thanks for the advice. However, the error came without that package in the beginning. I need to check whether the execSync function is available, otherwise use the syncExec (such as link below). Let's test the fix I just pushed first.

Also, thank you for making the node-milights-promise package!

@Lucas183 I forgot to fix the same error in another part of the code, try again please :). It is possible that the update system (latest version) might not work, but this is a temporary fix.

I'll use syncexec (like they did here https://github.com/lerna/lerna/commit/062ae97ea8b33be825670baa43c76f422fd603e6 to solve the same problem) in the future to solve it, if it works like this.

Also, like @mwittig said, make sure you are using a recent NodeJS version.

Lucas183 commented 6 years ago

Hi all,

sorry, I was on vacation, so I wasn't able to test it until now. The issue above seems to be solved, now I get a different one, probably because I did not set it up correcttly, maybe you can help me here.

img_20170825_154729 When I try to control my MiLights with an UDP Sender App I use a different port but that one isn t working either.