Skip to content

Support for Android / Termux (process.platform === 'android' ) #274

Closed

Description

@Manamama

Describe the bug

When running npkill on Termux (Android), it crashes immediately with:

TypeError: OSService[getOS(...)] is not a constructor

Root cause

Node.js on Termux reports process.platform === 'android'.

In the published package (v0.12.2) the platform map only contains:

const OSService = {
  linux: LinuxFilesService,
  win32: WindowsFilesService,
  darwin: MacFilesService,
};

So OSService['android'] is undefined.

Suggested fix

Treat Android the same as Linux (it is Linux under the hood and the existing LinuxFilesService works correctly after the patch).

Minimal patch (works on current published version):

// before
const getOS = () => process.platform;

// after
const getOS = () => 
  process.platform === 'android' ? 'linux' : process.platform;

Alternatively, just add the key:

const OSService = {
  linux: LinuxFilesService,
  android: LinuxFilesService,   // ← add this
  win32: WindowsFilesService,
  darwin: MacFilesService,
};

Environment

  • Termux on Android
  • Node.js v24.x (also reproduces on earlier versions)
  • npkill 0.12.2

Additional context

After applying the one-line change above, npkill starts and works normally on Termux.

NB. Grok xAI found the line and wrote the above.

Proof that works:

-----                    __   .__.__  .__
-           ____ ______ |  | _|__|  | |  |
------     /    \\____ \|  |/ /  |  | |  |        Releasable space: 0.00 GB
----      |   |  \  |_> >    <|  |  |_|  |__      Space saved: 0.00 GB
--        |___|  /   __/|__|_ \__|____/____/      Search completed 0.36s
-------        \/|__|        \/       0.12.2                               
                                                                   
  CURSORS for select - SPACE to delete                                                                                                                                                          Last_mod   Size   


on Termux above

Activity

  1. Manamama commented on Oct 15, 2026

    @Manamama
    Author

    Aha, and one liner to fix/patch it for now:
    sed -i "s/const getOS = () => process.platform;/const getOS = () => process.platform === 'android' ? 'linux' : process.platform;/" main.js

  2. kukirin-ui commented on Oct 15, 2026

    @kukirin-ui
    Contributor

    The android -> linux mapping Manamama posted looks like the cleanest fix. I can open a small PR with it, plus a test that fakes process.platform so it stays covered.

  3. zaldih commented on Nov 1, 2026

    @zaldih
    Member

    Fixed in #275 ! Thank you so much for tracking this down :)

    It will ship with v1.0. Until then, your one-liner is a great workaround!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions