Allowing packages to detect if they're called through npm/npx

I’m running into an issue where a code generation package needs to make assumptions about which package manager the user prefers based on the command used. For example, npx (which is also used by npm create/init) keeps exactly the same environment variables as running the package’s executable with Node directly, making it difficult to detect when it’s used so that npm can be enabled automatically. I’d appreciate help if there’s some other way I can observe the environment to guess if npm/npx is used, otherwise I’d like to propose that we inject and environment variable to detect its usage.

Here’s the issue if anyone’s interested in looking into it further: https://github.com/facebook/create-react-app/issues/7672

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.