Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.cpus: Cannot read property 'length' of undefined #25483

Closed
Lesmiscore opened this issue Jan 14, 2019 · 3 comments
Closed

os.cpus: Cannot read property 'length' of undefined #25483

Lesmiscore opened this issue Jan 14, 2019 · 3 comments
Assignees
Labels
android Issues and PRs related to the android platform. os Issues and PRs related to the os subsystem.

Comments

@Lesmiscore
Copy link

Lesmiscore commented Jan 14, 2019

  • Version: v11.6.0
  • Platform: Linux localhost 4.9.96-g641303d-ab5108637 #0 SMP PREEMPT Fri Nov 2 19:33:38 UTC 2018 aarch64 Android
  • Subsystem: os

Steps to reproduce

  1. Install Termux on Pixel 3 (Android 9)
    • Worked normally on Nexus 5X (Android 7.1.2)
  2. Install nodejs via apt
  3. Try npm i -g npm (or any other install command)
    • Very minimal reproducing code: require('os').cpus()
  4. See log

Problem

require('os').cpus() throws error.

Full 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   'npm' ]
2 info using npm@6.5.0-next.0
3 info using node@v11.6.0
4 verbose npm-session d6d3aa36df417d22
5 verbose stack TypeError: Cannot read property 'length' of undefined
5 verbose stack     at Object.cpus (os.js:94:28)
5 verbose stack     at Object.<anonymous> (/data/data/com.termux/files/usr/lib/node_modules/npm/node_modules/worker-farm/lib/farm.js:6:56)
5 verbose stack     at Module._compile (internal/modules/cjs/loader.js:721:30)
5 verbose stack     at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
5 verbose stack     at Module.load (internal/modules/cjs/loader.js:620:32)
5 verbose stack     at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
5 verbose stack     at Function.Module._load (internal/modules/cjs/loader.js:552:3)
5 verbose stack     at Module.require (internal/modules/cjs/loader.js:657:17)
5 verbose stack     at require (internal/modules/cjs/helpers.js:22: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 (internal/modules/cjs/loader.js:721:30)
5 verbose stack     at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
5 verbose stack     at Module.load (internal/modules/cjs/loader.js:620:32)
5 verbose stack     at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
5 verbose stack     at Function.Module._load (internal/modules/cjs/loader.js:552:3)
5 verbose stack     at Module.require (internal/modules/cjs/loader.js:657:17)
6 verbose cwd /data/data/com.termux/files/home/btcaddr-test
7 verbose Linux 4.9.96-g641303d-ab5108637
8 verbose argv "/data/data/com.termux/files/usr/bin/node" "/data/data/com.termux/files/usr/bin/npm" "i" "-g" "npm"
9 verbose node v11.6.0
10 verbose npm  v6.5.0-next.0
11 error Cannot read property 'length' of undefined
12 verbose exit [ 1, true ]
@richardlau
Copy link
Member

See #19022 (comment).

@Trott Trott added the android Issues and PRs related to the android platform. label Jan 14, 2019
@vsemozhetbyt vsemozhetbyt added the os Issues and PRs related to the os subsystem. label Jan 14, 2019
@JungMinu JungMinu self-assigned this Jan 14, 2019
@JungMinu
Copy link
Member

JungMinu commented Jan 14, 2019

going to open a PR to resolve this issue

@JungMinu
Copy link
Member

Fixed in 2b401e3

BridgeAR pushed a commit that referenced this issue Jan 16, 2019
For an unsupported OS, a call to os.cpus() throws an error
within os.cpus() itself where it tries to get the length of it.
This fixes the issue by adding fallback for undefined CPUs.

Fixes: #25483
PR-URL: #25493
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
BridgeAR pushed a commit to BridgeAR/node that referenced this issue Jan 16, 2019
For an unsupported OS, a call to os.cpus() throws an error
within os.cpus() itself where it tries to get the length of it.
This fixes the issue by adding fallback for undefined CPUs.

Fixes: nodejs#25483
PR-URL: nodejs#25493
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
BridgeAR pushed a commit to BridgeAR/node that referenced this issue Jan 17, 2019
For an unsupported OS, a call to os.cpus() throws an error
within os.cpus() itself where it tries to get the length of it.
This fixes the issue by adding fallback for undefined CPUs.

Fixes: nodejs#25483
PR-URL: nodejs#25493
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issues and PRs related to the android platform. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants