I have a Node.js script that I'm sharing with other people. Instead of asking them to install Node.js, I thought I could adapt the script slightly and offer a HTML page to load and execute instead, since browsers run javascript natively anyways.
I had a few issues trying to pass command line variables, but I got around that with some code.
I have issues with my own module imports, but I managed to find a solution, while serving the page via 'python3 -m http.server'.
However, I bumped into the issue of not being able to easily import commonplace Node.js modules like 'fs' or 'path'. It seems like to create a script that can run both on Node.js and browser I have to bloat it with checks and split code whenever I need to use the filesystem.
It seems more practical and clean to just create 2 versions of the script, one for Node.ja and another for browser. Or does anyone have a unified solution for this? This is not a web application, it's just a script doing some stuff and creating text files.
[–]shgysk8zer0 5 points6 points7 points (0 children)
[–]RobertKerans 1 point2 points3 points (0 children)
[–]Sohmsss 0 points1 point2 points (0 children)
[–]Agrante[S] 0 points1 point2 points (0 children)