Node.js on my Synology DS213J
So i decided to see if it was possible to run Node.js from my NAS, and turns out it easier than you would think.
Some nice guys at SynoCommunity has a neat project called SPKSRC, its an easy crosscompiling tool for createing a SPK package for DSM.
First of all you need some linux box, i used a VM running Ubuntu 12.04 LTS.
Then you need some stuff for the compiling.
[email protected]ker:~$ sudo apt-get update [email protected]:~$ sudo apt-get install build-essential debootstrap python-pip automake libgmp3-dev libltdl-dev libunistring-dev libffi-dev ncurses-dev imagemagick libssl-dev pkg-config zlib1g-dev gettext git curl subversion checkintltool gperf flex bison xmlto php5 expect libgc-dev mercurial cython lzip
According to SynoCommunity's example you also need bjam, but on ubuntu im told that its obsolete and libboost1.48-dev and libboost1.46-dev replaces it, so i installed them aswell.
[email protected]:~$ sudo apt-get install libboost1.48-dev libboost1.46-dev
Okay, now we are ready to clone the SPKSRC repo
[email protected]:~$ git clone https://github.com/SynoCommunity/spksrc.git
We now have all we need to get started with building node.js for the NAS.
cd spksrc/spk/node make arch-armada370
If you are not using a DS213j, just replace "armada370" with the architecture of your NAS, you can check out a list here: What kind of CPU does my NAS have
If everything went well you should now have a folder called ´packages´ in the root of spksrc.
If not? check out But my make failed
[email protected]:~$ cd spksrc/packages/node [email protected]:~/spksrc/packages/node$ ls node_armada370_0.10.6-1.spk
There its is, now just open up DSM, go to Package Center and click "Manual Install" and choose the spk you just compiled.
Voila! you now have Node.js on your Synology NAS.
Adding node to path
Lets tryout node real quick:
SSH to your nas with a tool like putty, and login with root and your normal admin password.
Now you can try and type node, and you should get an error: -ash: node: not found..
This is okay, node just isnt added to path, and this is real easy to fix.
Now before we can add it to path, we need to know where the node binaries are located. Mine was at /volume1/@appstore/node/bin/, but you can find yours easy by doing this:
Bekker-Nas> find / -name node /usr/syno/etc/packages/node /usr/local/node find: /proc/13093: No such file or directory find: /proc/13094: No such file or directory find: /proc/13096: No such file or directory find: /proc/13097: No such file or directory find: /proc/13098: No such file or directory find: /proc/13099: No such file or directory find: /proc/13100: No such file or directory find: /proc/13101: No such file or directory find: /proc/13102: No such file or directory find: /proc/13103: No such file or directory /var/packages/node /volume1/@appstore/node /volume1/@appstore/node/bin/node << THERE IT IS /volume1/@tmp/pkglist.tmp/icon/INST/node
Lets do a quick check
Bekker-Nas> cd /volume1/@appstore/node/bin/ Bekker-Nas> ls node npm
The files are there, now lets add it to path
Bekker-Nas> PATH=/volume1/@appstore/node/bin:$PATH Bekker-Nas> echo $PATH /volume1/@appstore/node/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/syno/sbin:/usr/syno/bin:/usr/local/sbin:/usr/local/bin
That looks right, lets do a test and run a helloworld.js file i upped to the nas
Bekker-Nas> node helloworld.js Hello Synology!
Enjoy your new node.js server!
But my make fails
Some people (including myself) had a problem when running the makecommand, and gets an error like this:
Makefile:19: *** armada370 is not a supported architecture. stop.
If this is the case, we need to make a small edit of a file.
[email protected]:~$ vim spksrc/cross/node/Makefile
Now replace ifneq ($(findstring $(ARCH),88f6281 bromolow cedarview x86),$(ARCH)) with ifneq ($(findstring $(ARCH),88f6281 bromolow cedarview x86 armada370),$(ARCH)) (just replace armada370 with your arch.)
Now try to make again, and now everythin should be fine.