Skip to content

Commit

Permalink
Add dotenvx to dynamically manage environment variables
Browse files Browse the repository at this point in the history
The real problem I'm running into is that different versions of node can
support wildly different options in NODE_OPTIONS.

For example `--no-experimental-global-navigator` will be required to make
things work on Node 22, but it isn't recognized at all on older versions,
and throws an error if we try to include it.

I fixed this by adding `scripts/node_options.js` to dynamically decide
which options to use depending on the node version, and dotenvx to set
the enviroment up before running node.

This makes the `npm run` scripts a bit clunky, because they need to
call `dotenvx run --quiet -- ` before doing `node whatever`,
but for now it seems like the least bad option.

This commit also removes `.npmrc` which was great but can only set the
NODE_OPTIONS to a single string.
  • Loading branch information
bhousel committed Sep 10, 2024
1 parent cd97768 commit 19c3e74
Show file tree
Hide file tree
Showing 5 changed files with 278 additions and 10 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NODE_OPTIONS=$(node 'scripts/node_options.js')
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

257 changes: 257 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 19c3e74

Please sign in to comment.