jishi / node-sonos-http-api

An HTTP API bridge for Sonos easing automation. Hostable on any node.js capable device, like a raspberry pi or similar.
http://jishi.github.io/node-sonos-http-api/
MIT License
1.85k stars 460 forks source link

Problem running node sonos http api on Synology NAS #121

Closed kwestGIT06 closed 8 years ago

kwestGIT06 commented 8 years ago

OK so I have followed the instructions and it seems I am still getting errors. I have installed node.js package from Synology (node -v v0.12.6). DS415+ Brand new Echo:-(

Looking at some of the post am I suppose assume that it will not work because of the node version? Node v4.x.x is needed? Below is my output - can anyone tell me what I have wrong?

WEST-NET1> npm install --production npm WARN package.json sonos-http-api@0.17.0 No license field. WEST-NET1> npm start

sonos-http-api@0.17.0 start /node-sonos-http-api-master node server.js

no settings file found, will only use default settings http server listening on port 5005 module.js:489 throw err; ^ SyntaxError: /node-sonos-http-api-master/presets.json: Unexpected token < at Object.parse (native) at Object.Module._extensions..json (module.js:486:27) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at /node-sonos-http-api-master/lib/actions/preset.js:32:17 at FSReqWrap.cb as oncomplete

npm ERR! Linux 3.10.35 npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start" npm ERR! node v0.12.6 npm ERR! npm v2.11.2 npm ERR! code ELIFECYCLE npm ERR! sonos-http-api@0.17.0 start: node server.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the sonos-http-api@0.17.0 start script 'node server.js'. npm ERR! This is most likely a problem with the sonos-http-api package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node server.js npm ERR! You can get their info via: npm ERR! npm owner ls sonos-http-api npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /node-sonos-http-api-master/npm-debug.log WEST-NET1>

NovaGL commented 8 years ago

You need node v4 or higher for the latest version to work, upgrade and your issue will resolve itself.

kwestGIT06 commented 8 years ago

OK. Thanks. There is no node v4 package for my Synology..ugh! So much for my excitement Guess I will see if I can figure out how to compile it for my Synology processor.

jishi commented 8 years ago

There are precompiled versions for ARMv6, v7 and v8. Try to identify which architecture your CPU is and replace the binaries with the precompiled ones. Node.js has very few dependencies and you can usually just replace the straight up.

kwestGIT06 commented 8 years ago

Thanks jishi, I checked my DS415+ is Intel Atom C2538 (x86_64) (Avoton). Didn't see any precompiled version. Oh Well. I will do some research to see if I can compile the source code for my architecture myself.

jishi commented 8 years ago

Well, there are of course precompiled versions för x86 and x64. It is the regular Linux versions.

okoeth commented 8 years ago

This is the version I'm using (on Ubuntu, not Synology--my Synology is still an old ARM version :-/ https://nodejs.org/download/release/v4.2.4/node-v4.2.4-linux-x64.tar.gz

kwestGIT06 commented 8 years ago

OK..finally got the node and npm installed but still having an issue when trying to run the server. Getting "Error: Cannot find module 'sonos-discovery'" and "npm ERR! Failed at the sonos-http-api@0.17.0 start script 'node server.js'."

Below is what I did....please see if I missed anything?

WEST-NET1> cd /usr/local/ WEST-NET1> tar --strip-components 1 -xzf /tmp/node-v4.2.4-linux-x64.tar.gz WEST-NET1> node -v v4.2.4 WEST-NET1> npm version { npm: '2.14.12', ares: '1.10.1-DEV', http_parser: '2.5.0', icu: '56.1', modules: '46', node: '4.2.4', openssl: '1.0.2e', uv: '1.7.5', v8: '4.5.103.35', zlib: '1.2.8' } WEST-NET1> npm ls /usr/local └── (empty) WEST-NET1> npm install production npm WARN deprecated CSSselect@0.7.0: the module is now available as 'css-select' npm WARN deprecated CSSwhat@0.4.7: the module is now available as 'css-what' production@0.0.2 node_modules/production ├── commander@1.1.1 (keypress@0.1.0) ├── request@2.12.0 ├── yuglify@0.1.4 (nopt@2.1.2, ycssmin@1.0.1, uglify-js@1.3.5) └── cheerio@0.10.3 (underscore@1.8.3, entities@0.5.0, htmlparser2@2.6.0, cheerio-select@0.0.3) WEST-NET1> WEST-NET1> npm ls /usr/local └─┬ production@0.0.2 ├─┬ cheerio@0.10.3 │ ├─┬ cheerio-select@0.0.3 │ │ └─┬ CSSselect@0.7.0 │ │ ├── boolbase@1.0.0 │ │ ├── CSSwhat@0.4.7 │ │ ├─┬ domutils@1.4.3 │ │ │ └── domelementtype@1.3.0 │ │ └── nth-check@1.0.1 │ ├── entities@0.5.0 │ ├─┬ htmlparser2@2.6.0 │ │ ├── domelementtype@1.3.0 │ │ ├── domhandler@2.0.3 │ │ └── domutils@1.0.1 │ └── underscore@1.8.3 ├─┬ commander@1.1.1 │ └── keypress@0.1.0 ├─┬ request@2.12.0 │ ├─┬ form-data@0.0.3 │ │ ├── async@0.1.9 │ │ └─┬ combined-stream@0.0.3 │ │ └── delayed-stream@0.0.5 │ └── mime@1.2.7 └─┬ yuglify@0.1.4 ├─┬ nopt@2.1.2 │ └── abbrev@1.0.7 ├── uglify-js@1.3.5 └── ycssmin@1.0.1

WEST-NET1> WEST-NET1> npm start

sonos-http-api@0.17.0 start /usr/local/node-sonos-http-api-master node server.js

module.js:340 throw err; ^

Error: Cannot find module 'sonos-discovery' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:289:25) at Module.require (module.js:366:17) at require (module.js:385:17) at Object. (/usr/local/node-sonos-http-api-master/server.js:4:22) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Function.Module.runMain (module.js:467:10)

npm ERR! Linux 3.10.35 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" npm ERR! node v4.2.4 npm ERR! npm v2.14.12 npm ERR! code ELIFECYCLE npm ERR! sonos-http-api@0.17.0 start: node server.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the sonos-http-api@0.17.0 start script 'node server.js'. npm ERR! This is most likely a problem with the sonos-http-api package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node server.js npm ERR! You can get their info via: npm ERR! npm owner ls sonos-http-api npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /usr/local/node-sonos-http-api-master/npm-debug.log WEST-NET1>

rahulrajus commented 8 years ago

Try installing sonos-discovery npm install sonos-discovery

kwestGIT06 commented 8 years ago

Thanks slickboy......looks like that did it. There were a few more so I did the same. fire up the browser with port 5005 and got below ...I assume that's what is expected?

[{"uuid":"RINCON_B8E937B49EE401400","coordinator":{"uuid":"RINCON_B8E937B49EE401400","state":{"currentTrack":{"artist":"","title":"WSB","album":"","albumArtURI":"/getaa?s=1&u=x-sonosapi-stream%3as27637%3fsid%3d254%26flags%3d32%26sn%3d0","duration":0,"uri":"x-sonosapi-stream:s27637?sid=254&flags=32&sn=0","radioShowMetaData":"The Mark Arum

jishi commented 8 years ago

Looks correct, that is probably some left over debug logging that I've introduced. I have had several reports of this not running correctly on Sonology for some reason, and we never got to the bottom of why that is. Mainly the Atom-based versions. YMMV.

And you shouldn't need to run npm install several times. You forgot the dual dash (--production) when running, that might have confused things.

skouthon commented 8 years ago

Hi guys, first of all thanks a lot for sharing your experience, it really helped me a lot in installing the server on my Synology NAS. does anybody know why I get this error on my ds1512 Sinology NAS (I had to remove my presets.son file in order for the server to start ): SyntaxError: /volume1/homes/admin/amazon-echo/node-sonos-http-api/presets.json: Unexpected token { at Object.parse (native) at Object.Module._extensions..json (module.js:450:27) at Module.load (module.js:356:32) at Function.Module._load (module.js:313:12) at Module.require (module.js:366:17) at require (module.js:385:17) at /volume1/homes/admin/amazon-echo/node-sonos-http-api/lib/actions/preset.js:32:17 at FSReqWrap.cb as oncomplete

jishi commented 8 years ago

Sounds like your preset file has invalid syntax. Run the content of the file through some online json validator, and it will probably point out what's wrong.

libatiba commented 8 years ago

Error: Cannot find module ./. resolveFilename-Error on Synology-NAS On Synology DS415+ I figured out, that the problem "Error: Cannot find module '/.../node-sonos-http/lib/actions/' at Function.Module._resolveFilename (module.js...)" is caused by hidden directories that are created by an indexing service of the NAS. The .js-modules tries to enumerate all files in a directory - but on Synology hidden subdirectories cause the routine to fail. The directories start with the @-sign e.g. @eaDir. Deleting the directory (and subdirectories) solved my problems completely!

klappenbach commented 8 years ago

thanks libatiba that solved my problem too, recursively deleting all @folders under the sonos-folder :) Now this works in my Synology 415play 👍

autofrank commented 8 years ago

Hi Gabbah, Did you install it in a docker container or natively on the DS I also have a DS415Play and was hoping to use it for the sonos api as well but couldn't find instructions

Thanks Frank