How can I install npm on termux

Viewed 24422

I'm trying to install npm using the npm install command on android termux and I got errors is there a way to go about this

If there is way please help

4 Answers

I think you could be a little more specific on the errors you got. Anyway I think you can install nodejs package on termux using pkg install nodejs which will install node and npm on your device. Then check the version using npm -v.

It is very simple:- After installing termux open app and run command

apt update 
apt upgrade

After that simply write

pkg install nodejs-lts 

Or Write

npm

After writing npm termux will say "npm package is not installed , install by executing //code And you are done run here are the two options .. Hope it helps

It is important: after install termux from store, open the console, and update/upgrade it to latest version. The checks in the following list are skippables.

// system update, there could be changes to the state of store version
apt-get update && apt-get upgrade

//check linux version ( 2021.01.19. current:  apt/stable 2.1.15, Linux 4.4.23+)
termux-info

// Access Android and Chrome hardware features.
apt install termux-api

// install nodejs
apt install nodejs

//check npm version ( 2021.01.19. current:  6.14.10)
npm -v

// check node version (current: v14.15.4)
node -v

Install

Make sure you've first installed the termux-api on your Android device from the Play store.

Then install the scripts with apt install termux-api.

Finally get this node module:

$ npm install --save termux

Example usage
const api = require('termux')

if (!api.hasTermux) process.exit(1)

api.vibrate()
   .duration(1000)
   .run()

api.clipboardGet()
   .run()
   .then(function (text) {
     // ...
   })

This is from my side if you still face any issue please feel free to ask.

Related