I used a Docker container to build NodeJS, information :
https://github.com/dockcross/dockcross
You cannot run NodeJS versions higher than 0.10.*. Older versions of NodeJS can be downloaded:
https://nodejs.org/en/download/releases/. I'm currently using Node.js 0.10.4, not the latest version, but I used an older version because of compile issues. The latest 0.10 version will probably work though.
I eventually used the second procedure as described on
https://techsparx.com/software-developm ... mpile.html to perform the compilation of NodeJS. It is similar to the one on the original Crossdock site though. It doesn't work out of the box. Tweaks are contained in the procedure below.
I use a Synology DS716+II for running the container. Create a separate folder for this. This requires command line shell and docker.
Put the NodeJS version 0.10 download in the same folder, and untar (tar -xvf <file.tar>)
cd to the newly created directory (node-v0.10.something)
In that folder, run the steps from the site mentioned above:
docker run --rm dockcross/linux-armv5 >dockcross-linux-armv5
chmod +x dockcross-linux-armv5</nowiki>
I ran the whole thing as root, so the last command was not necessary in my case
The site mentions moving the produced file, but I don't see the need for that for a temporary project.
If you have already used the Dockcross container, and want to compile a new project (different version of NodeJS for example), you need to do a make clean first:
./dockcross-linux-armv5 bash -c '.make clean'
Run the configure command:
./dockcross-linux-armv5 bash -c './configure --without-snapshot --dest-cpu=arm --dest-os=linux'
I disabled ssl at first because I do not use it, so wanted to keep the installation smaller. But when re-executing my own procedure, npm gave me troubles because it wants to use https to connect to the package repository. So I removed the --without-ssl option in the above command for that to work.
Now, an additional step is necessary, as described on
https://blog.cepharum.de/en/post/instal ... heezy.html
edit (vi) deps/v8/src/arm/macro-assembler-arm.cc
look for lines reading like this
// We always generate arm code, never thumb code, even if V8 is compiled to
// thumb, so we require inter-working support
#if defined(__thumb__) && !defined(USE_THUMB_INTERWORK)
#error "flag -mthumb-interwork missing"
#endif
// We do not support thumb inter-working with an arm architecture not supporting
// the blx instruction (below v5t). If you know what CPU you are compiling for
// you can use -march=armv7 or similar.
#if defined(USE_THUMB_INTERWORK) && !defined(CAN_USE_THUMB_INSTRUCTIONS)
# error "For thumb inter-working we require an architecture which supports blx"
#endif
Adjust it to read like this:
// We always generate arm code, never thumb code, even if V8 is compiled to
// thumb, so we require inter-working support
#if defined(__thumb__) && !defined(USE_THUMB_INTERWORK)
#error "flag -mthumb-interwork missing"
#endif
#if !defined(CAN_USE_THUMB_INSTRUCTIONS)
# define CAN_USE_THUMB_INSTRUCTIONS 1
#endif
// We do not support thumb inter-working with an arm architecture not supporting
// the blx instruction (below v5t). If you know what CPU you are compiling for
// you can use -march=armv7 or similar.
#if defined(USE_THUMB_INTERWORK) && !defined(CAN_USE_THUMB_INSTRUCTIONS)
# error "For thumb inter-working we require an architecture which supports blx"
#endif
Now you can build node, using:
./dockcross-linux-armv5 bash -c 'make -j4'
My Synology is not the fastest, so compiling does take some time. The j4 option makes the compiler use 4 threads, so depending on the number of cpu/cores on the host machine this can be changed to speed up things.
The build will fail in the end, with the following error:
/usr/bin/arm-linux-gnueabi-ld: bad -rpath option
This can be fixed by changing the linker in out/Makefile. Originally reads:
LINK.target ?= /usr/bin/arm-linux-gnueabi-ld
Needs to be:
LINK.target ?= /usr/bin/arm-linux-gnueabi-g++
Another build can now be started, and just the linker part will be executed again, so it will be done quite fast
./dockcross-linux-armv5 bash -c 'make -j4'
I tried to change this earlier on, but that didn't stick somehow. The option is set in the container's ENV. I tried overriding the ENV, but that also did not work. So had to go with the above workaround.
I haven't packaged the result, so I moved the files manually via SFTP.
Note: Not all directories needed already exist, so you need to create some yourself (/usr/local/ for example)<br />
Copy out/Release/node to /usr/local/bin
Copy deps/npm directory to /usr/local/lib/node_modules/
cd /usr/local/bin
ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js npm
Before you can run npm, you need to set an environment variable:<br />
export NODE_PATH='/usr/local/lib/node_modules'
Might be an option to set this in your startup script, else commands will fail when you login again.
The current MQTT V2 removed support for older NodeJS versions, so the latest release you can use is 1.14.1:
npm install -g mqtt@1.14.1
Now you can test with a simple NodeJS script from
https://github.com/mqttjs/MQTT.js/tree/v1.14.1#connect
var mqtt = require('mqtt');
var client = mqtt.connect('mqtt://test.mosquitto.org');
client.on('connect', function () {
client.subscribe('presence');
client.publish('presence', 'Hello mqtt');
});
client.on('message', function (topic, message) {
// message is Buffer
console.log(message.toString());
client.end();
});
It should say "hello MQTT".
==Todo==
Check security. Node runs as root, can that be a different user?
Thanks for the info on the rrd, will have a look at that. Still requires https calls though, it seems. Also, there's nothing in my mnt folder. Seems that my folders are setup differently.