How to run Node.js Express Server in Android

Sushil Bhardwaj
3 min readNov 14, 2019
Express.js

If you are curious about node.js want to run on Android then, you arrived at the right place. In this blog, we are going to learn how to built node.js server using the express framework. As you know our smart android phones can do pretty much everything as we want if we know the way how to do it?

Termux Apk

Termux Command Line Interface

Before we start let me introduce to an app which we are going to use known as Termux. It is a Terminal Emulator for android and it is pretty much similar to a Linux environment where you can run basic Linux commands and Install arm based packages. This app is available on play store for free.

Installation and Configuration

Go to google play store and search for Termux or follow the links. after Installation, You have to update the packages so type the following commands

$ pkg update && pkg upgrade

after the completion of the update process now its time to install node.js in android so type the following command

$ pkg install nodejs

after installing node.js on your machine now we are familiar with the next process which is installing Express. But before installing Express we need a command line TextEditor like vim, nano, etc so let’s install those to

$ pkg install vim

ok now finally we can install the express server but wait lets make a directory where we can store our project so again

$ mkdir express-in-android && cd express-in-android
$ npm install express --save

finally, we have installed the express server, and now it’s time to make a server.js file and inserting some base code, and test our server.

$ vim server.js/* Simple Express.js Server */
const express = require(‘express’)
const app = express()
const port = 3000
app.get(‘/’, (req, res) => res.send(‘Hello World!’))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))

$ node server.js

Now execute the above command in your terminal. This should print the text “Example app listening on port 3000” on your console. Now open the web browser(Chrome) and visit localhost:3000. You will get a message “Hello World!

Wrapping it up

Termux is an amazing app. With this app not only you can install and run express but also you can install and run front-end frameworks like Angular, React, Vue, etc. In this app, we can also install C-lang, python, and other programming languages. You can also do pip install Django and start making applications on Django. It also supports git. You can install git from the package manager `pkg install git` and start pushing code to GitHub.

Thank you for being with me, I hope you have learned something from this blog. Till then stay connected…

☮️

--

--