vercel/pkg

Can't install using npm in termux

NurTasin opened this issue · 3 comments

What version of pkg are you using?

I was unable to install it and that is my problem

What version of Node.js are you using?

v18.13.0

What operating system are you using?

Android (Termux)

What CPU architecture are you using?

arm64

What Node versions, OSs and CPU architectures are you building for?

node18-arm64

Describe the Bug

I was trying to install pkg on my Android Phone using Termux. It already has a binary named pkg (used to install packages, just like apt) . So when I try to install this pkg using npm install pkg the following error pops up saying that a binary with same name already exists.

npm ERR! code EEXIST
npm ERR! path /data/data/com.termux/files/usr/bin/pkg
npm ERR! EEXIST: file already exists
npm ERR! File exists: /data/data/com.termux/files/usr/bin/pkg
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:

I tried to install it with an alias like npm install -g jspkg@npm:pkg but the same thing happend.
What should I do? I want my js code to be ran on termux.
NOTE: I can't use --force to overwrite the binary as It is needed to install many packages within termux.

Expected Behavior

I kind of expected this error. But are there any work arround to this? I am sure that some other distros also use pkg as their system package manager.

To Reproduce

Here I tried to install it normally

Screenshot_20230820-201537_Termux

And here I tried to install it with an alias

Screenshot_20230820-201559_Termux

this is because of termux's pkg, which is an apt wrapper.

[pkg] performs a number of tasks:

  • Provides command shortcuts. Use "pkg in" instead of "pkg install" or "apt install".
  • Automatically runs "apt update" before installing a package if necessary.
  • Performs some client side repository load-balancing by automatically switching mirrors on a regular basis. That is important to prevent us hitting quota limit on hosting.

source: https://wiki.termux.com/wiki/Package_Management

this is because of termux's pkg, which is an apt wrapper.

[pkg] performs a number of tasks:

  • Provides command shortcuts. Use "pkg in" instead of "pkg install" or "apt install".
  • Automatically runs "apt update" before installing a package if necessary.
  • Performs some client side repository load-balancing by automatically switching mirrors on a regular basis. That is important to prevent us hitting quota limit on hosting.

source: https://wiki.termux.com/wiki/Package_Management

I know that. But will it work if I just remove pkg (apt wrapper) and then try to install pkg?

@NurTasin you can install pkg locally and then run it with npx:
npx pkg <whatever>