raunioroo
raunioroo•9mo ago

Deny env permissions silently (without throwing)

Hi. An npm module I'm using tries to read, or rather check for an existence of an env variable. The problem is it throws due to not having permission to access env. I'd rather not give any env permissions to any of my scripts. I think the offending npm module can do with having env variables undefined, it's just that it throws just trying to see if the variables are there. Can I somehow make Deno silently return empty/null without throwing an error? (if it's any importance, the offending module is npm:deepl-node , which uses npm:axios, which tries to see if there is something in NODE_EXTRA_CA_CERTS and is then unable to handle the access denied exception)
3 Replies
cknight
cknight•9mo ago
I think you'd need to grant permission, which you could do to just that env var. E.g. --allow-env=NODE_EXTRA_CA_CERTS. If you wanted to avoid any code possibly using that env var, you could always remove this env combined with the above. E.g. Deno.env.delete("NODE_EXTRA_CA_CERTS");
raunioroo
rauniorooOP•9mo ago
Yeah, that doesn't look very pretty, but would work, thank you! Deleting the variable afterwards might be overprotective, but would definitely make me feel less dirty haha.
cknight
cknight•9mo ago
Choose your dirt 😅