Skip to content

Add a way to get the enabled conditions #55824

Description

@sapphi-red

What is the problem this feature will solve?

Currently there is no way to get the enabled conditions easily. It requires checking process.env.NODE_OPTIONS and process.execArgv which is not robust. It should be noted that although it is an edge case, the process.env.NODE_OPTIONS check should be done before any code that modifies that variable.

Some concrete cases:

  1. Give custom resolvers to imitate Node.js's resolution (this one can be solved if parent parameter of import.meta.resolve is out of experimental, but I guess exposing conditions is less controversial than graduating that API from experimental)
  2. Let frameworks to show a warning when the user didn't set required / expected conditions.
    • For example, if frameworks expect users to set custom conditions, to show a warning they have to parse the conditions to do that for now.

What is the feature you are proposing to solve the problem?

Add conditions variable in node:module.

Example code:

// node -C development ./foo.mjs
import { conditions } from 'node:module';
console.log(conditions) // ['development']

I didn't add node to conditions in the example above, but maybe it makes sense to add that too.
But for import and require, I'm not sure if those should be added in that case. Probably the option would be to add both or neither.

What alternatives have you considered?

Activity

  1. added
    moduleIssues and PRs related to the module subsystem.
    on Nov 14, 2024
  2. moved this from Awaiting Triage to Triaged in Node.js feature requestson Nov 14, 2024
  3. github-actions commented on May 13, 2025

    @github-actions
    Contributor

    There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the never-stale Issues and PRs exempt from automated stale handling. label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment.
    For more information on how the project manages feature requests, please consult the feature request management document.

  4. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on May 13, 2025
  5. github-actions commented on Jun 12, 2025

    @github-actions
    Contributor

    There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

    For more information on how the project manages feature requests, please consult the feature request management document.

  6. sapphi-red commented on Jun 12, 2025

    @sapphi-red
    ContributorAuthor

    The PR is open at #57688 and is approved by 3 people.

  7. added a commit that references this issue on Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.moduleIssues and PRs related to the module subsystem.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions