maddox / dasher

🔘 A simple way to bridge your Amazon Dash buttons to HTTP services
MIT License
710 stars 93 forks source link

Errors During 'npm install' in Two Environments #19

Open BzowK opened 8 years ago

BzowK commented 8 years ago

Hey - Thanks for the script. Trying to use, but cannot get working. Have tried setting up in two separate linux environments with same issue. Below is environment, procedure i followed, and results. Any suggestions? Thanks

Environment

I also tried Ubuntu 15.10 inside VM Workstation /w bridged NIC and got similar results

Procedure

  1. Obtained MAC of Dash from router
  2. Ran 'apt-get update' to update source
  3. Installed git, npm, & libpcap-dev without issue
  4. Created SSH key and added to my git account
  5. Ran 'git clone git@github.com:maddox/dasher.git' to clone repo successfully
  6. Ran 'npm install'. Got following echo...
pi@KNCar:~ $ npm install
npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open '/home/pi/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! System Linux 4.1.19-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/pi
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! path /home/pi/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/npm-debug.log
npm ERR! not ok code 0
  1. Since it couldn't find package.json, I changed directory to the dasher root (~/dasher) and ran 'npm install' again to get this echo:
pi@KNCar:~/dasher $ npm install
npm WARN engine socketwatcher@0.3.0: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})

> socketwatcher@0.3.0 install /home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher
> node-gyp rebuild

make: Entering directory '/home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher/build'
  CXX(target) Release/obj.target/socketwatcher/socket_watcher.o
In file included from ../socket_watcher.hpp:8:0,
                 from ../socket_watcher.cpp:5:
../../nan/nan.h:324:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
   static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
                                               ^
socketwatcher.target.mk:82: recipe for target 'Release/obj.target/socketwatcher/socket_watcher.o' failed
make: *** [Release/obj.target/socketwatcher/socket_watcher.o] Error 1
make: Leaving directory '/home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 4.1.19-v7+
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! socketwatcher@0.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the socketwatcher@0.3.0 install script.
npm ERR! This is most likely a problem with the socketwatcher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls socketwatcher
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 4.1.19-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/pi/dasher
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN engine hawk@3.1.3: wanted: {"node":">=0.10.32"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine cryptiles@2.0.5: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine hoek@2.16.3: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine boom@2.10.1: wanted: {"node":">=0.10.40"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/dasher/npm-debug.log
npm ERR! not ok code 0
  1. Finally, I decided to try to launch it anyways to see what happened so from the root of ~/dasher ran 'sudo npm run start' and got the below:
pi@KNCar:~/dasher $ sudo npm run start

> dasher@1.1.1 start /home/pi/dasher
> node app.js

module.js:340
    throw err;
          ^
Error: Cannot find module 'node-dash-button'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/pi/dasher/lib/dasher.js:2:18)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

npm ERR! dasher@1.1.1 start: `node app.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the dasher@1.1.1 start script.
npm ERR! This is most likely a problem with the dasher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls dasher
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.1.19-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "run" "start"
npm ERR! cwd /home/pi/dasher
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/dasher/npm-debug.log
npm ERR! not ok code 0

Any suggestions? Am I leaving out a big step? Thanks!

UPDATE After posting, I went back to the Ubunutu 15 VM. I installed nodejs-legacy then tried again and this time 'npm install' again and this time it completed without errors. I had tried installing it in Raspbian on my RP, but it was already installed and up to date so doesn't help there. Would still much prefer to run on RP so the above post is still valid as all notes come from its installation. Thanks!

UPDATE #2 OK, ok, I spoke too soon... 'npm install' seemed to be successful as I didn't see any error messages. I edited the example config file (below) and then saved it in the same path as config.json. While still in the 'dasher' root, I then ran 'sudo npm run start' - it started! I clicked my dash button and after a few seconds, the terminal flooded with about 20 mesage about EthernetFrame. The trigger from IFTTT never went so I clicked the button again. Almost instantly, I got the echo "undefined press" followed by many lines of echo in the terminal. I quit npm, then tried launching it again but got errors. All of the events described are below followed by my config file...

ben@ubuntu:~/dasher$ sudo npm run start

> dasher@1.1.1 start /home/ben/dasher
> node app.js

undefined added.
undefined added.
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
node_pcap: EthernetFrame() - Don't know how to decode ethertype 35033
undefined pressed.
there was an error
[Error: SELF_SIGNED_CERT_IN_CHAIN]

/home/ben/dasher/lib/dasher.js:38
    if (response.statusCode === 401) {
                ^
TypeError: Cannot read property 'statusCode' of undefined
    at Request.onResponse [as _callback] (/home/ben/dasher/lib/dasher.js:38:17)
    at self.callback (/home/ben/dasher/node_modules/request/request.js:200:22)
    at Request.EventEmitter.emit (events.js:95:17)
    at Request.onRequestError (/home/ben/dasher/node_modules/request/request.js:831:8)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at CleartextStream.socketErrorListener (http.js:1547:9)
    at CleartextStream.EventEmitter.emit (events.js:95:17)
    at SecurePair.<anonymous> (tls.js:1389:19)
    at SecurePair.EventEmitter.emit (events.js:92:17)
    at SecurePair.maybeInitFinished (tls.js:982:10)

npm ERR! dasher@1.1.1 start: `node app.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the dasher@1.1.1 start script.
npm ERR! This is most likely a problem with the dasher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls dasher
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.2.0-16-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "run" "start"
npm ERR! cwd /home/ben/dasher
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ben/dasher/npm-debug.log
npm ERR! not ok code 0
ben@ubuntu:~/dasher$ sudo npm run start

> dasher@1.1.1 start /home/ben/dasher
> node app.js

module.js:485
    throw err;
          ^
SyntaxError: /home/ben/dasher/config/config.json: Unexpected token ]
    at Object.parse (native)
    at Object.Module._extensions..json (module.js:482:27)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/ben/dasher/app.js:2:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

npm ERR! dasher@1.1.1 start: `node app.js`
npm ERR! Exit status 8
npm ERR! 
npm ERR! Failed at the dasher@1.1.1 start script.
npm ERR! This is most likely a problem with the dasher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls dasher
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.2.0-16-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "run" "start"
npm ERR! cwd /home/ben/dasher
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ben/dasher/npm-debug.log
npm ERR! not ok code 0

My (Edited) config.json file

{"buttons":[
  {
    "address": "mymacaddress",
    "url": "https://maker.ifttt.com/trigger/Notify/with/key/mykey",
    "method": "POST"
  },
]}

Thoughts? Thanks!

jettw commented 8 years ago

I'm having the same issue. I've tested this on a Raspberry Pi 3 / Raspbian Jessie & on LXC Ubuntu 14.04 LTS

Is there any work arounds? I would love to get this working with HA

ez2remember commented 8 years ago

I'm having the same issue as BzowK on the Raspberry Pi 3 with Raspbian.

legotheboss commented 8 years ago

@jettw @ez2remember @BzowK try installing the latest version of Node... For Raspberry Pi, use these commands:

wget http://node-arm.herokuapp.com/node_latest_armhf.deb 
sudo dpkg -i node_latest_armhf.deb
AceoStar commented 7 years ago

@BzowK @ez2remember @jettw I'm not sure if you are still tracking this thread, but I had just about every issue you did and I think we've cleaned things up a bit so that it should work on your Raspberry Pi. Would you mind testing out the pull request? https://github.com/almcelmon/dasher.git https://github.com/almcelmon/dasher. Big thanks to @legotheboss for the ideas on pulling it all together.

jettw commented 7 years ago

@almcelmon Thanks so much! I just did a pull on my Ubuntu LXC & everything is working now. I set up two dash buttons that are connected to home assistant. awesome

webdigi commented 7 years ago

Had the same issue and nothing would work. Finally had to go to node 0.10.26 on the pi.

Used NVM instead of direct node install. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash nvm install 0.10.26

maxisme commented 7 years ago

@webdigi Worked! Thank you!

edbyford commented 7 years ago

Hello - I'm having the same problem as OP. I have followed each of the steps in this thread and now I receive an "Unexpected token ILLEGAL" error (see below). Any suggestions? Can I provide any other logs etc?

pi@hassbian:~/dasher $ npm install
SyntaxError: Unexpected token ILLEGAL
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:414:25)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/node_modules/hawk/lib/index.js:7:18)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
npm ERR! Linux 4.4.50-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.2.1
npm ERR! npm  v2.14.7

npm ERR! Unexpected token ILLEGAL
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
edbyford commented 7 years ago

I started with a fresh install just in case one of my intermediate "remedial" steps had caused this to error. I followed the steps above and now have the below error. Any ideas?

pi@hassbian:~/dasher $ npm install
npm WARN engine socketwatcher@0.3.0: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})

> socketwatcher@0.3.0 install /home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher
> node-gyp rebuild

make: Entering directory '/home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher/build'
  CXX(target) Release/obj.target/socketwatcher/socket_watcher.o
In file included from ../socket_watcher.hpp:8:0,
                 from ../socket_watcher.cpp:5:
../../nan/nan.h:326:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
   static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
                                               ^
socketwatcher.target.mk:82: recipe for target 'Release/obj.target/socketwatcher/socket_watcher.o' failed
make: *** [Release/obj.target/socketwatcher/socket_watcher.o] Error 1
make: Leaving directory '/home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 4.4.38-v7+
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! socketwatcher@0.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the socketwatcher@0.3.0 install script.
npm ERR! This is most likely a problem with the socketwatcher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls socketwatcher
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 4.4.38-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/pi/dasher
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/dasher/npm-debug.log
npm ERR! not ok code 0
pi@hassbian:~/dasher $
nikhilkhade commented 7 years ago

I am having a similar issue as ebdyford while installing dasher for HA on my Raspberry Pi3. Any suggestions will be highly appreciated.

pi@Hassbian:~/dasher $ npm install
npm WARN engine socketwatcher@0.3.0: wanted: {"node":">=4"} (current: {"node":"0.10.29","npm":"1.4.21"})

> socketwatcher@0.3.0 install /home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher
> node-gyp rebuild

make: Entering directory '/home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher/build'
  CXX(target) Release/obj.target/socketwatcher/socket_watcher.o
In file included from ../socket_watcher.hpp:8:0,
                 from ../socket_watcher.cpp:5:
../../nan/nan.h:326:47: error: ‘REPLACE_INVALID_UTF8’ is not a member of ‘v8::String’
   static const unsigned kReplaceInvalidUtf8 = v8::String::REPLACE_INVALID_UTF8;
                                               ^
socketwatcher.target.mk:82: recipe for target 'Release/obj.target/socketwatcher/socket_watcher.o' failed
make: *** [Release/obj.target/socketwatcher/socket_watcher.o] Error 1
make: Leaving directory '/home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:809:12)
gyp ERR! System Linux 4.4.50-v7+
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/pi/dasher/node_modules/node-dash-button/node_modules/pcap/node_modules/socketwatcher
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! socketwatcher@0.3.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the socketwatcher@0.3.0 install script.
npm ERR! This is most likely a problem with the socketwatcher package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls socketwatcher
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 4.4.50-v7+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/pi/dasher
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/dasher/npm-debug.log
npm ERR! not ok code 0
sekisek commented 7 years ago

Hi, @nikhilkhade @edbyford did you manage to solve it??

I am stuck with the same errors and versions.

legotheboss commented 7 years ago

@sekisek Your node is out of date. Run these commands:

sudo apt-get remove nodejs
wget http://node-arm.herokuapp.com/node_latest_armhf.deb 
sudo dpkg -i node_latest_armhf.deb