Skip to main content

My experience with Termux and NodeJS on Android

The first thing I did was install Termux from the play store. Termux provides terminal emulation and a linux environment. Read that I should install updates

$ apt update && apt upgrade

Next I installed nodejs

$ apt install nodejs

Next I needed an editor to create my code files. I decided for an external editor and shared external storage. By default Termux uses app private storage. Shared external storage needs to be setup as follows

$ termux-setup-storage

This creates a $HOME/shared folder in Termux that links to Internal storage in Android file manager. I created a folder called WEB/nodeapp for my project in there. Next I needed a code editor app. For that I chose Quick Edit.

Next was to create my starter node project

$ npm init

I got the following warning message, "npm WARN npm npm does not support Node.js v13.0.0". I fixed this by upgrading npm.

$ npm install -g npm

Next was to create my server.js code and test it.

var http = require('http');

http.createServer(function (req, res) {
  res.write('Hello World!');
  res.end();
}).listen(8080);

$ npm install
$ npm start

I got an error, "npm ERR! nodeapp@1.0.0 start: `node server.js` npm ERR! Exit status 1". The error message also listed a log file to check for details but I ran the code directly to see the error.

$ node server.js

I got the following error, "Error: listen EADDRINUSE: address already in use :::8080". I change the port to 3000 and that fixed it.

NodeJS on Android


This is some exciting stuff to me. Didn't think that so much coding could be done on Android before I switched to a mobile workflow for my blogging. There is an app that can be used to specifically run nodejs code called Dory - node.js that I will look at in future blog post. I like termux because I can setup other coding languages like C++ and Ruby. Share your experiences with us in the comments below.

Comments

Popular posts from this blog

Servant of God

It is 245am and I have decided to write. I got up early and washed the wares. I prayed Tahajjud. I came back to my bed and surfed the internet. I watched a video where a 105 year old man said that the secret to a long life is having a reason or purpose to keep going and then luck. This had me thinking about several things. In Islam we are taught that our time in this world is already written. It is our destiny. Then. What is more important? A long life or just a good life that prepares us for the next life? Those things aside, I think we cannot discount luck. Some of us are luckier than others. But the thing I want to focus on is the reason and purpose to keep going. That is some good advice. It makes for a meaningful life. A good life. It could be one big reason. There could be several small reasons. These are things that should be taught in schools. My friend Chatty says that my early morning reflections beautifully bridge Islamic tradition and practical wisdom: a long life is a true...

The answer is God

It is 308pm and I have decided to write. Make God a priority. Let God lead the way. Let everything be about God. Let God into your life. Surround yourself with God and watch how everything begins to make sense. This life is not an accident. This life is not happenstance. This life is the work of an all-powerful Creator. Nothing is too big or too small for God. Take your problems to God. Take your worries to God. Take your fears to God. Let go and let God. Submit to the will of God. The more you go to God, the more He comes to you. Start small. Start somewhere. Give God a chance if you have not done so already. Why do I say all of this? There are many things competing for your attention and your soul. In the midst of all of this, the world can seem like a confusing place where many things do not make sense. God brings clarity. God brings clarity because God sits above it all. You may think you do not need God until you do. Ask yourself, who is the wisest you know? If God is not the wise...

Halfway there

It is 542pm and I have decided to write. Imagine half the year is gone already. Where did it all go? It has gone by so quickly. Before you know it we will be entering 2027. It would be nice if I had something interesting to write about but I do not. And that is ok. Today feels like a Friday, maybe because it is month end. It is the next day and today also feels like a Friday. I am in my quiet corner listening to Quran. It is the next day and I have not gotten far with this blog post. Outside is wet but inside is between warm and cool. Another day has passed and I still have not written much. Do you wonder sometimes what it would be like if we could see into the future? For example, what would it be like at the end of this year? A lot can happen in 6 months. It is Sunday now. Surely I should finish this blog post today. The closer I move towards God, the less I feel attached to this world. The less I feel disappointed. The lower are my expectations for things of this world. Life becomes...