Description
As of npm 11, it's possible to use the node-options
configuration key to specify the content of NODE_OPTIONS
for lifecycle scripts (i.e. it wouldn't be picked up, for example, by npm test ...
-- but it would be from npm pretest ...
).
I'm wondering whether it would be feasible thinking about the idea of allowing users to opt-in into using this configuration key to set NODE_OPTIONS
for npm commands as well.
I'm not hard-set on this solution, I'll share some context around why I'm making this proposal.
Context
As a software engineer at Gradle, I'm part of a team which is adding support for npm to our build observability product, Develocity.
We created a module that can be preloaded (NODE_OPTIONS="-r ..."
) and, when enabled, collects events from the run and sends them to the Develocity server.
We realized that setting NODE_OPTIONS
can have ergonomics issues: setting it globally means that the module cannot be found for projects that don't have the package installed (and would be picked up by any Node.js process), and unfortunately using node-options
from the npm config would not have an effect when running, for example npm test
.
I'm open to discuss other solutions that would fit well with our use case of instrumenting npm.