How to run node.js on Android?
I just had a jaw-dropping moment—Termux allows you to install Node.js on an Android device!
It works well for basic tasks, such as running a WebSocket speed test. The HTTP server it creates can be accessed both locally and over the network.
There’s a Medium post detailing the installation process, which essentially involves:
Installing Termux Running apt install nodejs Starting Node.js with node One limitation I encountered is that shared folders might not have the necessary permissions to install modules. This could be due to file permissions. However, the private app storage works perfectly fine for this purpose.
You can use Node.js for mobile apps with the Node.js for Mobile Apps(Node.js for Mobile Apps) project. It supports Android devices and simulators, with pre-built binaries available for armeabi-v7a, x86, arm64-v8a, and x86_64. It also works on iOS, though that’s outside the scope of this discussion.
Similar to JXcore, Node.js for Mobile Apps hosts a Node.js engine within the same process as the app, but it operates in a dedicated thread. Unlike JXcore, it is essentially pure Node.js built as a library with a few portability fixes for Android. This approach makes it easier to keep the project up-to-date with the latest Node.js versions.
Additionally, there are plugins available for Cordova and React Native. These plugins facilitate communication between the JavaScript side of these frameworks and the Node.js engine, and they simplify development by handling tasks like packaging modules and cross-compiling native modules at build time.
Full disclosure: I work for the company that develops Node.js for Mobile Apps
@Priyada Panicker, Thanks! It works great and fully satisfies my needs with npm and support for multiple files. Although I ended up not using it, it’s reassuring to know it’s available.
I almost got the canvas to work, but I would need to take some additional steps in Linux (currently using Windows). I found a replacement library that doesn’t require Canvas, which works well for my purposes.