4 ms·
Also a NodeJS fan in general, but prefer to install/develop cli's with golang instead of node just because you get a compiled, static binary that works cross-pl
by diggan 9y ago
Also a NodeJS fan in general, but prefer to install/develop cli's with golang instead of node just because you get a compiled, static binary that works cross-platform. Faster for users to install, less bloaty and works on all platforms without any dependencies.
- 52-6F-62 9y agoI personally usually use Python, Bash, or C, but there is a utility for packaging NodeJS tools into executables. I think it does some tree-shaking as well. Disclaimer: I haven't used it, so I'm not sure of the results. But it is possible. https://www.npmjs.com/package/pkg https://www.npmjs.com/package/pkg edit: For the curious -- Just tried on a really simple script that just takes one argument and writes it with some text to STDOUT and it still came to 35MB. So it must package a bunch of Node with it. I won't be leaving my go-to's for it anytime soon unless usability and development speed necessitate it. Going to have to go with the, best to not use NodeJS for general cmd-line utils outside of the NodeJS environment. The one perk is that it will, by default, output executables for Linux, macOS, and Windows. Source: (function() { 'use strict'; function main(_string) { console.log(`${_string} was read from STDIN.`); } main(process.argv[2]); }()); Output file: 35088858 Nov 20 11:36 index-linux 35717043 Nov 20 11:36 index-macos 23137020 Nov 20 11:36 index-win.exe
- WildGreenLeave 9y agoThats because PKG is including the Node runtime in the binaries, this way users don't have to install Node itself to run them. I'm using it myself and besides the fat binaries and the fact that you have to write Javascript, it is really good. (Working on replacing this daemon with Go ASAP) Edit: just read your last line, I'm kinda stating the obvious here.