Problem in installing node-red on android

#1

i get this error when trying to install node-red on android:
cannot read property ‘length’ of undefined

this error shown when i type: npm i -g --unsafe-perm node-red

1 Like
#2

Did you precede that with

pkg install coreutils nodejs
#3

i’ve preceded it with:
apt install coreutils nano nodejs

like in this link:
https://nodered.org/docs/platforms/android

#4

which version of Android ? What does node -v and npm -v report back ?
(must admit we don’t regularly test on Android - are there any more error messages than just that one line ?)

#5

Also, since you are using apt rather than pkg, run

apt update
apt upgrade

to make sure everything is the latest version. It probably won’t help but worth doing.

#6

I did this on a cheap ($60) Blu Android 6 phone with Ting as the provider ($10/month since I do no data and no phone calls and never come close to exceeding 300 texts) and use a node red flow to monitor system status (Internet connection, AC power, heartbeat of my IOT Pi3B+ and Beaglebone etc.) and send me SMS messages when something is amiss.

Works great until some Android update makes it spontaneously reboot and it all stops until I dismiss a toast dialog :frowning: Seems to happen once a month or more.

The Beaglebone which is the main MQTT broker sends an Email to inform me if the Android flow “will” message is received.

Android really needs a new settings switch – “Everything meets all my needs, don’t F’ with it!”

Here are my notes from the installation, straight from a discussion on Google Groups from about a year ago:

// From the Android Play store install:
Termux
Termux:API
//
// start the termux app and run the following commands:
apt update
apt upgrade
apt install coreutils nano nodejs
npm i -g --unsafe-perm node-red
node-red
apt install termux-api
//
// start node red in termux app:
node-red

I made a .profile setting to autostart it, I’d have to look on the phone to see what it was as I forgot to put it in my notes, but it also came from the Google Groups discussion from back then. Termux sells an autostart app, which I was planning to buy, but so far haven’t needed to do so.

#7

I’m having the same problem.

node -v = v8.11.2
npm -v = 5.6.0

Ran all the preceding commands.

This is the error log:

.mux/files/home/.npm/_logs/2018-06-07T17_52_08_662Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ ‘/data/data/com.termux/files/usr/bin/node’,
1 verbose cli ‘/data/data/com.termux/files/usr/bin/npm’,
1 verbose cli ‘i’,
1 verbose cli ‘-g’,
1 verbose cli ‘–unsafe-perm’,
1 verbose cli ‘node-red’ ]
2 info using npm@5.6.0
3 info using node@v8.11.2
4 verbose npm-session 3415649d84795c1b
5 verbose stack TypeError: Cannot read property ‘length’ of un$
5 verbose stack at Object. (/data/data/com.term$
5 verbose stack at Module._compile (module.js:652:30)
5 verbose stack at Object.Module._extensions…js (module.j$
5 verbose stack at Module.load (module.js:565:32)
5 verbose stack at tryModuleLoad (module.js:505:12)
5 verbose stack at Function.Module._load (module.js:497:3)
5 verbose stack at Module.require (module.js:596:17)
5 verbose stack at require (internal/module.js:11:18)
5 verbose stack at Object. (/data/data/com.term$
5 verbose stack at Module._compile (module.js:652:30)
5 verbose stack at Object.Module._extensions…js (module.j$
5 verbose stack at Module.load (module.js:565:32)
5 verbose stack at tryModuleLoad (module.js:505:12)
5 verbose stack at Function.Module._load (module.js:497:3)
5 verbose stack at Module.require (module.js:596:17)
5 verbose stack at require (internal/module.js:11:18)
6 verbose cwd /data/data/com.termux/files/home
7 verbose Linux 4.4.78-perf+
8 verbose argv “/data/data/com.termux/files/usr/bin/node” "/da$
9 verbose node v8.11.2
10 verbose npm v5.6.0
11 error Cannot read property ‘length’ of undefined
12 verbose exit [ 1, true ]

#8

Which version of Android (usually in Settings > About Phone)?

#9

I’m on a One Plus 5T running 8.1.0

#10

can you npm install any other packages ? eg npm i -g npm to get the latest version of npm.

As is “usual” I have just tried a clean install on my Android tablet and it all installed fine… which doesn’t help.

But see here for a thread on this in Termux - https://github.com/npm/npm/issues/19265 including possible workaround - but not a permanent fix.

#11

Interesting, I get the same error running npm i -g npm

I’ll take a look at the work around tomorrow, thanks.

#12

I tested the workaround, and NPM works now.

“Ha yeah that problem. I just manually edited /usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js to set maxConcurrentWorkers to 1. Then npm will work again.”

#13

node -v returns: 8.11.2
npm -v returns :5.6.0
i’m on nexus 4, android version: 8.1

#14

It seems there is a known problem with npm on Android 8


It is not clear to me from that whether there is any ongoing action to fix it.

How to use node red in Android 8 smartphone
#15

Had the same problem, fixed with typing:
apt-get install yarn yarn global add npm

Got the solution from here, https://github.com/termux/termux-packages/issues/1855

2 Likes