This repository has been archived by the owner. It is now read-only.

NPM ERR! Cannot read property 'length' of undefined #19265

Open
trusktr opened this Issue Nov 29, 2017 · 8 comments

Comments

Projects
None yet
4 participants
@trusktr
Copy link

trusktr commented Nov 29, 2017

I'm opening this issue because:

  • npm is crashing.
  • npm is producing an incorrect install.
  • npm is doing something I don't understand.
  • Other (see below for feature requests):

What's going wrong?

$ npm i
npm ERR! Cannot read property 'length' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /data/data/com.termux/files/home/.npm/_logs/2017-11-29T00_21_20_773Z-debug.log
$ npm -v
5.5.1

$ cat /data/data/com.termux/files/home/.npm/_logs/2017-11-29T00_21_20_773Z-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' ]
2 info using npm@5.5.1
3 info using node@v9.2.0
4 verbose npm-session 4aceefa3e6169750
5 verbose stack TypeError: Cannot read property 'length' of undefined
5 verbose stack     at Object.<anonymous> (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js:5:61)
5 verbose stack     at Module._compile (module.js:641:30)
5 verbose stack     at Object.Module._extensions..js (module.js:652:10)
5 verbose stack     at Module.load (module.js:560:32)
5 verbose stack     at tryModuleLoad (module.js:503:12)
5 verbose stack     at Function.Module._load (module.js:495:3)
5 verbose stack     at Module.require (module.js:585:17)
5 verbose stack     at require (internal/module.js:11:18)
5 verbose stack     at Object.<anonymous> (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/worker-farm/lib/index.js:3:14)
5 verbose stack     at Module._compile (module.js:641:30)
5 verbose stack     at Object.Module._extensions..js (module.js:652:10)
5 verbose stack     at Module.load (module.js:560:32)
5 verbose stack     at tryModuleLoad (module.js:503:12)
5 verbose stack     at Function.Module._load (module.js:495:3)
5 verbose stack     at Module.require (module.js:585:17)
5 verbose stack     at require (internal/module.js:11:18)
6 verbose cwd /data/data/com.termux/files/home/src/trusktr+infamous
7 verbose Linux 4.4.56-g594d847d09a1
8 verbose argv "/data/data/com.termux/files/usr/bin/node" "/data/data/com.termux/files/usr/bin/npm" "i"
9 verbose node v9.2.0
10 verbose npm  v5.5.1
11 error Cannot read property 'length' of undefined
12 verbose exit [ 1, true ]

How can the CLI team reproduce the problem?

Install Termux for Android, then pkg install nodejs-current then npm i -g npm.

supporting information:

  • npm -v prints: 5.5.1
  • node -v prints: 9.2.0
  • npm config get registry prints:
  • Windows, OS X/macOS, or Linux?: Linux (Termux)
  • Network issues:
    • Geographic location where npm was run:
    • I use a proxy to connect to the npm registry.
    • I use a proxy to connect to the web.
    • I use a proxy when downloading Git repos.
    • I access the npm registry via a VPN
    • I don't use a proxy, but have limited or unreliable internet access.
  • Container:
    • I develop using Vagrant on Windows.
    • I develop using Vagrant on OS X or Linux.
    • I develop / deploy using Docker.
    • I deploy to a PaaS (Triton, Heroku).
@bradjc

This comment has been minimized.

Copy link

bradjc commented Nov 29, 2017

I believe this can be fixed by updating the dependency "worker-farm" to version 1.5.2 as it includes this commit: rvagg/node-worker-farm@0b2349c

@trusktr

This comment has been minimized.

Copy link

trusktr commented Nov 30, 2017

@bradjc How would you recommend updating the dependency considering npm won't run?

@bradjc

This comment has been minimized.

Copy link

bradjc commented Nov 30, 2017

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.

@trusktr

This comment has been minimized.

Copy link

trusktr commented Dec 29, 2017

Thanks, that workaround works. Why am I getting this though? I mean, with the workaround I was able to run npm i -g npm to install NPM 5.6.0, and I would think that NPM would not come with a dependency that doesn't work. Is it because of my architecture or OS that worker-farm wasn't accounting for?

@braytak

This comment has been minimized.

Copy link

braytak commented Jan 2, 2018

@bradjc: on Termux Android, the manual edit allows upgrading to nmp 5.6.0 as you say, but further installs fail on the "length" error still!
Very disruptive bug...

@braytak

This comment has been minimized.

Copy link

braytak commented Jan 2, 2018

@bradjc please disregard my previous comment, your fix does workaround the issue.
Sorry; my bad.

@vanessayuenn

This comment has been minimized.

Copy link

vanessayuenn commented Jan 11, 2018

@trusktr I was wondering the same thing and did some digging. According to this thread (termux/termux-packages#1798), it looks like it fails on npm performing a check for cpu info that's not permitted on Android.

@trusktr

This comment has been minimized.

Copy link

trusktr commented Jan 11, 2018

Does Node os need to be fixed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.