import-meta-env
import-meta-env copied to clipboard
Alternatives for building in air-gapped (offline) environment.
The Issue:
the NPM pkg utility is no longer maintained. I struggled finding ways to "package" inside an offline (air-gapped) environment.
By default pkg reaches out to the internet (npm registry). It would be a very tedious process bringing binaries for PKG_CACHE_PATH to build offline.
The Workaround:
Resort to a shell script that is able to work offline on an nginx-alpine that performs sed -i "s|\"import_meta_env_placeholder\"|\"$json_object\"|g" ./index.html instead.
Suggested Feature: Is it possible to use Node SEA (Node 21+) to build the executable in an offline environment instead?
You can use Node SEA to build the executable, but be aware that it is still experimental.
I wasn't able to figure out the best way to use Node SEA, but it seems like @yao-pkg/pkg is being maintained, so i moved to that 🤷