Termux-packages: NPM ERR! Cannot read property 'length' of undefined

Created on 15 Aug 2018  路  6Comments  路  Source: termux/termux-packages

npm/npm#19265
npm/npm#1855

This disruptive bug is still not elegantly fixed. Can we get a reliable fix from standard install please?

Unpacking nodejs-current (9.11.1) ...
Processing triggers for man (1.14.4) ...
Setting up nodejs-current (9.11.1) ...
$ node -v
v9.11.1
$ npm -v
5.6.0
bug report help wanted

Most helpful comment

replace $cpu with number of cores (or 1 if unsure)

sed -i "s|require('os').cpus().length|$cpu|g" /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js

All 6 comments

Would it be resolved by updating nodejs-current to v10 #2621 ?

I have same error :/

replace $cpu with number of cores (or 1 if unsure)

sed -i "s|require('os').cpus().length|$cpu|g" /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js

It should be noted that it may have to do with it being the beta version of termux because I couldn't get this fixed to work but as soon as I downgraded to the non beta version of termux and applied this fix it worked right away

replace $cpu with number of cores (or 1 if unsure)

sed -i "s|require('os').cpus().length|$cpu|g" /data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js

Can someone clarify? I have seen this 7 ways on seven sites/threads.
What i have in the un-edited file:
, maxConcurrentWorkers : (require('os').cpus() || { length: 1 }).length

I have tried changing it to a hard-coded 1, 4, and 8 (8 core phone) and deleting the rest of the line.
I have tried changing the { length: 1 } to { length: 8 } and to 4, and even tried reversing the order of the statement so the OR above evals first (long-shot).
I tried apt install yarn and then yarn add npm. Nothing makes npm work.

Using
nodejs 11.6.0
npm 6.5.0
Android 9 (OxygenOS 9.0.2)
Termux & apt fully updated system.

Is there a solution to this?!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

roalyr picture roalyr  路  3Comments

adit picture adit  路  3Comments

neitsab picture neitsab  路  3Comments

loveablefellow007 picture loveablefellow007  路  3Comments

jackbrycesmith picture jackbrycesmith  路  3Comments