Home›Termux Programming›How to Install Node.js and npm in Termux
Termux Programming

How to Install Node.js and npm in Termux

How to Install Node.js and npm in Termux

Node.js allows JavaScript programs to run outside a web browser. With Termux, you can install the available Node.js package, check the runtime version and experiment with small command-line programs directly on Android. The package names and versions may vary with repository state, so confirm what your device reports after installation. This guide sticks to Termux-managed packages and avoids unofficial all-in-one installers.

↓ Verify and Download Termux Android App · Official F-Droid ↗

Complete link verification to access the official Termux F-Droid download.

Install the Runtime

Run pkg update and then pkg install nodejs. If the repository exposes a differently named variant on your device, check the package search results before choosing it. After installation, confirm the runtime using node --version and the package manager using npm --version.

Run a Quick JavaScript Test

Open the Node.js REPL by entering node, then type console.log("Hello from Termux"). Exit with .exit or the terminal’s EOF shortcut. For a file, create hello.js with a text editor and run it with node hello.js.

Use npm for Project Dependencies

In a project folder, npm init can create a package manifest and npm install package-name can add a dependency. Review a package’s documentation and maintenance status before installing it. Avoid running arbitrary lifecycle scripts from unknown packages, especially when you do not know what permissions or files they may touch.

Troubleshooting and Limits

If a package cannot be found, update package metadata and check enabled Termux repositories. Native modules may need compilers or platform support and may not install cleanly on every Android device. Keep enough free storage for dependencies, and do not assume every desktop Node.js tool will work on a mobile environment.

Frequently Asked Questions

Does Node.js include npm?

The Termux package usually provides the Node.js runtime and npm tooling, but verify both commands after installation.

Can I run a local development server?

Many simple servers can run in Termux, but Android battery restrictions, network configuration and app lifecycle behavior can affect availability.

Is Node.js installation safe?

Use Termux’s configured package repositories and review third-party project commands before executing them.

Official reference: Termux installation notes on GitHub. Use the download button above to open the official F-Droid listing.

Safety note: Termux is a powerful command-line environment. Only install packages from trusted repositories and review commands before running them, especially when they request elevated privileges, personal data or broad file access.