iTranslated by AI
JavaScript (Node.js) on Termux
This is a detailed article based on the one mentioned above.
Typical JavaScript
When people talk about JavaScript, it is often used within script elements in HTML. Here is a typical example:
<span id="counter">0</span>
<script>
addEventListener("DOMContentLoaded", (event) => {
const counter_span = document.querySelector('#counter');
function countup(e) {
e.textContent = Number(e.textContent)+1;
}
setInterval(countup, 1000, counter_span);
});
</script>
Here, the "script element" refers to the part enclosed by <script> and </script>, indicating that the content inside is JavaScript.
Run a simple Python HTTP server in the directory where this file is located to host it:
~ $ python -m http.server
Opening http://localhost:8000/counter.html in your browser...

Note: You should see a tiny number in the top-left corner. Please zoom in to see it.
It works like this (you can also easily try it on sites like jsfiddle). Here, JavaScript is responsible for rewriting the number every second.
You can stop the running server with Ctrl+C.
The above was an example of JavaScript running in a web browser, but there are several environments where JavaScript can run in the CLI, similar to Python. In the following, we will use one of them, Node.js.
Node.js
This is an execution environment for the type of JavaScript known as server-side scripting.
Installing Node.js
~ $ pkg install nodejs-lts
If you are asked anything, just press ⏎ as usual.
Simple Installation Check
First, create a directory and move into it:
~ $ mkdir -p node/test
~ $ cd node/test
~/node/test $ npm init -y
Create a JavaScript file with a text editor:
Array(10).fill(0)
.map((_, i)=>i)
.forEach(e=>console.log(`${e+1}回目`));
Execute it with the node command (Node.js itself).
~/node/test $ node index.js
1回目
2回目
3回目
4回目
5回目
6回目
7回目
8回目
9回目
10回目
~/node/test $
It's kind of like Python, isn't it?
Learning JavaScript
This article does not explain how to write JavaScript itself.
First, let's learn the basics of JavaScript here. Since it also covers Node.js in the latter half, you will be able to see what kind of things are possible.
Development Using Vue
Next, we will use Node.js to create a simple SPA using Vue to get a feel for it (without API calls). As of May 2025, React is far more famous than Vue as a similar library, but since I am not familiar with React, I am explaining using Vue.
Running npm create vue@latest will scaffold a Vue development environment after you answer various questions.
~ $ mkdir -p node
~ $ cd node
~/node $ npm create vue@latest
> npx
> create-vue
┌ Vue.js - The Progressive JavaScript Framework
│
◇ Project name (target directory):
│ vue-example
│
◇ Select features to include in your project: (↑/↓ to navigate, space to select, a to toggle all,
enter to confirm)
│ none
Scaffolding project in /data/data/com.termux/files/home/node/vue-example...
│
└ Done. Now run:
cd vue-example
npm install
npm run dev
| Optional: Initialize Git in your project directory with:
git init && git add -A && git commit -m "initial commit"
~/node $ cd vue-example
~/node/vue-example $ npm install
...
~/node/vue-example $
At this point, the application template is ready. Running npm run dev will start the development server, and you can see the application in its initial state. Next, follow the instructions that were provided (in English).
~/node/vue-example $ npm run dev
Once it starts, you can open the browser by pressing o + enter to view it (enter refers to ⏎).

This is the application in its initial state. Since there isn't much to see, close it and return to the Termux screen, then exit with q + enter. Once you're back to the normal state, let's try some Git operations (this is optional).
~/node/vue-example $ git config --local user.email "you@example.com"
~/node/vue-example $ git config --local user.name "Your Name"
~/node/vue-example $ git init && git add -A && git commit -m "initial commit"
With this, although your name and email are placeholders, your configuration for this Git repository is complete, and your work history has been saved. The storage location is under .git/, and it's not visible to others, so don't worry.
After that, modify one top-level file in the template:
<script setup>
import Example from './components/Example.vue'
</script>
<template>
<main>
<Example/>
</main>
</template>
And create another file...
<script setup>
import { ref, computed } from 'vue'
const counter1 = ref(0)
const counter2 = ref(0)
const counter3 = computed(()=>{
return counter1.value + Number(counter2.value);
});
setInterval(()=>{counter1.value++;}, 1000);
</script>
<template>
<span>{{ counter1 }}</span> + <input type="number" v-model="counter2"> = <span>{{ counter3 }}</span>
</template>
Try it with the development server:
~/node/vue-example $ npm run dev # Adding -- --host 0.0.0.0 allows you to view it from a PC, etc.
The result of opening it in the browser, just like before, is as follows:

You can see that it works somewhat reactively. However, this isn't the result of server queries being reflected reactively; it's running only inside the browser, so it's just to get a feel for it.
And for those who performed the Git operations earlier:
~/node/vue-example $ git diff
Doing this allows you to check what has changed from the template. Since you can only see one screen at a time, you can scroll through using the arrow keys. Use the space bar to go forward one screen, and press p to go back one screen. To exit, press q. There are other features like searching similar to Vim, but you can look those up yourself (these are key operations for the less command).
Now that we have confirmed it works, we will perform a production build (transpilation).
~/node/vue-example $ npm run build
...
~/node/vue-example $
The artifacts are created in the dist directory. By placing these on a web server, you can host the application you tested on the development server. Let's try verifying it with a simple HTTP server...
~/node/vue-example $ cd dist
~/node/vue-example/dist $ npx http-server
...
When you access the displayed URL in your browser, you'll see the same screen as before. In other words, it's now in a state where it can run on any web server, even without Node.js. You might wonder if it's always like this with Vue or React—not necessarily, but it is for this code. Also, while you could see the source code earlier using the developer tools in a PC browser (Android browsers don't have them), in the production build, it's been transpiled, making it a bit harder to analyze.
Further Learning
Web development requires both front-end and back-end (roughly everything else) knowledge, and each requires a certain level of expertise, making the hurdle somewhat high. In contrast, most services that allow you to host web servers for free with JavaScript have restrictions that are too strict or are so slow they are practically useless, which I think can be quite stressful for children without money trying to learn.
So, at this point, I will break away from my dependency on JavaScript and choose to shift to PHP, which offers relatively abundant resources even for free. This is a choice to, in principle, not use server-side JavaScript in a production environment.
To be honest, PHP is not a language with a very bright future. However, most servers currently operating as a CMS are running WordPress, and while it is slowly declining, it will likely continue to operate for quite some time. This means that the PHP and MySQL that power WordPress will continue to run while maintaining a certain level of resources. Many of these services are available for free, often in exchange for displaying ads. They offer decent capacity, and most importantly, they come with a database. While you cannot use Node.js and will be sharing the server with others, the server specs themselves are much higher than those of a cheap VPS. If you can share a WordPress server that isn't heavily loaded, it can be used comfortably, and there aren't too many new users joining. While you might hesitate to use it for a domain you want to maintain for life, it’s not a bad option as a temporary learning server for use during your youth.
So, although it's a bit abrupt, this concludes the section on JavaScript.
Note that these days, JavaScript is often not used directly; TypeScript is now the standard for source code. Once you've learned to use JavaScript, try to become conversational in it, even if it's just the basics.
Discussion