Termux-packages: npm global modules not executable

Created on 16 Mar 2016  路  4Comments  路  Source: termux/termux-packages

Hey! Loving termux!

I'm a node.js developer and I just tried installing a npm module globally (-g or --global) and it installs just fine but when I go to use the module it gives an error:

npm i trymodule -g
$ trymodule colors
-bash: /data/data/com.termux/files/usr/bin/trymodule: /data/data/com.termux/files/usr/bin/env: bad interpreter: No such file or directory

However when I execute the module from the bin with node it works.

$ node /data/data/com.termux/files/usr/bin/trymodule colors

Any idea why I can't just call the global executable that npm installs?

When I go into these bin files for instance cat /data/data/com.termux/files/usr/bin/trymodule I see that the first line is rewritten from #!/usr/bin/env node to:

#!/data/data/com.termux/files/usr/bin/env node

Which is really odd.

Most helpful comment

The rewriting of #!/usr/bin/env node to #!/data/data/com.termux/files/usr/bin/env node is done since /usr does not exist on Android.

This is done by a patch to npm which invokes termux-fix-shebang on the installed programs in bin/.

The problem is that $PREFIX/bin/env is not installed by default - you can solve this by installing coreutils (which provides this file) with

apt install coreutils

There is an issue about $PREFIX/bin/env not being installed by default at #125, so closing this in favour of that one.

All 4 comments

The rewriting of #!/usr/bin/env node to #!/data/data/com.termux/files/usr/bin/env node is done since /usr does not exist on Android.

This is done by a patch to npm which invokes termux-fix-shebang on the installed programs in bin/.

The problem is that $PREFIX/bin/env is not installed by default - you can solve this by installing coreutils (which provides this file) with

apt install coreutils

There is an issue about $PREFIX/bin/env not being installed by default at #125, so closing this in favour of that one.

Hello, i have the same problem and i tried
apt install coreutils
But if no use.
Any help is appreciated. Thanks

Actually, it works with npm but not with yarn.

Thanks. Problem solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Wetitpig picture Wetitpig  路  3Comments

bkdwt picture bkdwt  路  3Comments

zejji picture zejji  路  4Comments

jackbrycesmith picture jackbrycesmith  路  3Comments

roalyr picture roalyr  路  3Comments