How To Create First NodeJS Application In Android
NodeJS Is A Runtime Environment That Allows You To Run JavaScript Code On The Server-Side. It Uses The V8 JavaScript Engine, Developed By Google For Chrome Browser, To Execute JavaScript Code Outside Of A Web Browser. NodeJS Is Commonly Used For Building Scalable Network Applications, Such As Web Servers, APIs, And Real-Time Applications, Due To Its Event-Driven, Non-Blocking I/O Model, Which Makes It Efficient And Lightweight.
NodeJS Is A Cross Platform JavaScript Runtime Environment Which Supported On Every Operating Systems Include Windows, macOS & Linux.
It Can Also Be Installed In Android OS Using Termux. In This Tutorial We Will Learn How To Install & Use NodeJS In Android.
1. Install Termux
Termux Is An Android Terminal Emulator And Linux Environment App That Allows Users To Run Various Linux Command-Line Utilities Directly On Their Android Devices. It Provides A Full-Fledged Linux Environment, Including Packages And Tools Such As Bash, Ssh, Git, And More, Enabling Users To Perform Tasks Like Programming, Development, And System Administration Directly From Their Smartphones Or Tablets.
To Install Termux Click Here.
2. Setup Termux Environment
Once Termux Is Installed In Your Android Device Necessary Packages Used To Run Termux Properly Will Be Installed In Your Android Device Automatically. So Nothing Is Excepted From You.
3. Install NodeJS & NPM
It Isn't Required But As A Good Practice Before You Install Any Packages Using Termux It Is Good To Update The Packages Repositories Using The Following Command For Any Changes.
Also You Need A Stable Internet Connection To Install Any Packages From Termux Repositories.
pkg upgrade
To Install NodeJS Using Termux Type The Following Command In Termux CLI(Command Line Interface).
pkg install nodejs
This Command Will Start Installing NodeJS In To Your Termux Environment. When The Installation Is In Progress It May Ask You To Confirm The Installation By Entering Y/n So Type Y & Press Enter.
After Installation Is Completed You Can Check NodeJS Is Installed In Your Termux Environment Using The Following Command.
node --version
At The Time Of Creating This Post The Latest Version Is Version 23.5.0.
Additionally NPM(Node Package Manager) Will Be Installed Automatically Which Is Used To Install NodeJS Libraries Like Python PIP (Package Installer For Python).
After Installation Is Completed You Can Check NPM Is Installed In Your Termux Environment Using The Following Command.
npm --version
At The Time Of Creating This Post The Latest Version Is Version 10.9.2.
4. Create You First NodeJS Application
To Write NodeJS Code In Android You Need A Text Editor. You Can Use Any Text Editor You Preferred. In My Side I Use MT Manager Text Editor For A Good Performance. You Can Also Install It From Android Developers Telegram Channel.
After That Create NodeJS File In Any Name You Want With .js Extension. For Instance HelloWorldApp.js.
I Have Written This Code In My NodeJS File.
console.log("Hello World");
4. Run You First NodeJS Application
To Run The NodeJS File We Created Earlier Back To Termux App & Navigate To The Directory Where Your Store Your NodeJS File Using The cd Command. In My Side I Stored My NodeJS File In My SDCard So I Use The Following Command.
cd /sdcard/
After That Type node Followed By Your NodeJS File Name For Instance HelloWorldApp.js
node HelloWorldApp.js
After Execution If Your NodeJS File Doesn't Have Any Compilation Error Termux Will Show You The Output Like This.
In This Way You Can Install & Use NodeJS In Android Using Termux.
Also There Are More Termux Tutorials On Android Developers YouTube Channel.
Thank You For Reading
Comments
Post a Comment