Adding modules to node.js on Android

530 views
Skip to first unread message

Ingo Albers

unread,
May 22, 2014, 10:04:20 AM5/22/14
to nod...@googlegroups.com
Hey,

I built node.js for my android device (Geniatech ATV1220) and it is running fine. I did it with ./android-configure and put the node executable on the device.

For a new project I need some modules (serialport, socket.io, express) but I can't use npm on my device. I tried building the modules on an ARM QEMU but those modules didn't work.

I was now trying to include the modules as core modules directly when building following these instructions: https://github.com/mapbox/node-sqlite3/wiki/Building-for-Android

But I am unsure what exactly I have to include. All the modules and also all the modules that those modules have as dependencies? This seems to be quite the effort and a lot of work to get those different versions to work together.

So my question is, what would be the best way to achieve it? Can I somehow run npm on the android? Or how would you tackle it?

Kind regards,
Ingo

Aria Stewart

unread,
May 22, 2014, 11:51:37 AM5/22/14
to nod...@googlegroups.com

On May 22, 02014, at 10:04, Ingo Albers <pjotr...@gmail.com> wrote:
>
> For a new project I need some modules (serialport, socket.io, express) but I can't use npm on my device. I tried building the modules on an ARM QEMU but those modules didn't work.

Why can’t you use npm? What have you tried?

signature.asc

Kevin Ingwersen

unread,
May 22, 2014, 12:02:56 PM5/22/14
to nod...@googlegroups.com
He is probably using a non-shell interactive thing…like FTP. I therefore would suggest to:

- Set CC, CXX, CFLAGS, CXXFLAGS, LDFLAGS correctly to point and use your NDK installation.
- npm install under this dev environment. node-gyp should pick these variables up and use them accordingly. As a result, you should have ARM binaries.
- Copy the resulting node_modules foder to your device/application folder and make sure nodejs can pick it up.

Ingo Albers

unread,
May 23, 2014, 2:46:14 AM5/23/14
to nod...@googlegroups.com, ingwi...@googlemail.com
I was following this tutorial to build node.js: https://gist.github.com/modeswitch/114c9bd55d800df242a2
So I only put the node executable on the device itself. 

Thank you Kevin, I will try to do it like that.

Ingo Albers

unread,
May 23, 2014, 7:36:23 AM5/23/14
to nod...@googlegroups.com, ingwi...@googlemail.com
I added the flags and it built socket.io and express, but I get the following error for serialport:

> seria...@1.1.3 install /home/ingo/23newfolder/box/node_modules/serialport
> node-gyp rebuild

make: Entering directory `/home/ingo/23newfolder/box/node_modules/serialport/build'
  CXX(target) Release/obj.target/serialport/src/serialport.o
arm-linux-androideabi-g++: error: unrecognized command line option '-m64'
make: *** [Release/obj.target/serialport/src/serialport.o] Error 1
make: Leaving directory `/home/ingo/23newfolder/box/node_modules/serialport/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.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-20-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/ingo/23newfolder/box/node_modules/serialport
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.10.9
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! seria...@1.1.3 install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1
npm ERR! 
npm ERR! Failed at the seria...@1.1.3 install script.
npm ERR! This is most likely a problem with the serialport 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 serialport
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-20-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/ingo/23newfolder/box
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ingo/23newfolder/box/npm-debug.log
npm ERR! not ok code 0
 

Ingo Albers

unread,
May 23, 2014, 9:44:11 AM5/23/14
to nod...@googlegroups.com, ingwi...@googlemail.com
Am Freitag, 23. Mai 2014 08:46:14 UTC+2 schrieb Ingo Albers:
Regarding my previous mail, that has not been published so far. I also tried using a newer node/npm and serialport version but then I get this error:

> seria...@1.3.1 install /home/ingo/23newfolder/box/node_modules/serialport
> node-gyp rebuild

Traceback (most recent call last):
  File "/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 18, in <module>
    sys.exit(gyp.script_main())
AttributeError: 'module' object has no attribute 'script_main'
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:340:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1046:12)
gyp ERR! System Linux 3.11.0-20-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ingo/23newfolder/box/node_modules/serialport
gyp ERR! node -v v0.11.13
gyp ERR! node-gyp -v v0.13.0
gyp ERR! not ok 
npm ERR! seria...@1.3.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the seria...@1.3.1 install script.
npm ERR! This is most likely a problem with the serialport 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 serialport
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-20-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/ingo/23newfolder/box
npm ERR! node -v v0.11.13
npm ERR! npm -v 1.4.9

Number 9

unread,
May 24, 2014, 2:55:16 AM5/24/14
to nod...@googlegroups.com
Hey
Very interested in this.

Can you put the output
/home/ingo/23newfolder/box/npm-debug.log into a gist please so we can iterate faster over the debugging.
Going to try and replicate your error this morning too.

Thanks
Anton

Ingo Albers

unread,
May 24, 2014, 1:09:59 PM5/24/14
to nod...@googlegroups.com

Ingo Albers

unread,
May 28, 2014, 4:32:42 AM5/28/14
to nod...@googlegroups.com
I have now tried to build the modules under debian kit on the android device, which seemed to work fine. But when I try to run my application I get an error that serialport could not load libstdc++.so.6. libstdc++6 is installed, so I am stuck again. Here is my build and error log:

Ingo Albers

unread,
May 28, 2014, 5:44:40 AM5/28/14
to nod...@googlegroups.com
I got it working now using debian kit on the device with node 10. Thanks for the help.

jery

unread,
Apr 14, 2015, 11:00:11 PM4/14/15
to nod...@googlegroups.com
Hi, I'm a newbie and  I'm very intrested in this issue. But i do not have any idea about how to do it , did you have any document (or tutorial) about how to make it work by using debian kit ?

在 2014年5月28日星期三 UTC+8下午5:44:40,Ingo Albers写道:

Ingo Albers

unread,
Apr 15, 2015, 7:17:51 AM4/15/15
to nod...@googlegroups.com
Hello jery,

I am personally not working on this project anymore. But basically all I did was install debian kit on my android device as described on the debian kit website: http://sven-ola.dyndns.org/repo/debian-kit-en.html

After I had the debian environment running on the android it was basically the same as in any desktop debian environment. apt-get install nodejs and apt-get install npm if I remember correctly.

Maybe this tutorial might help you: http://www.codemonkeez.com/2014/05/how-i-got-nodejs-and-mongodb-running-on.html

Kind regards
Ingo
Reply all
Reply to author
Forward
0 new messages