Skip to content

Clarify that devEngines is a conceptual subset of engines; solve for CI use #28

Open
@ljharb

Description

@ljharb

For an application, engines is useless, so one would only use devEngines (or only use engines), and the incremental value for devEngines is minimal

For a node npm package, the intended and common usage will be something perhaps like this (noting that "see a warning" may be replaced with "fail with an error" if configured as such):

  • engines.node would be eg ^20 || >= 22, indicating you can use node 20 or 22+
  • devEngines.runtime.node would be eg 22, indicating you should develop the package with node 22
  • when the package is being installed, users should see a warning unless they're on node 20 or 22+
  • when npm install is ran by a developer of the package, users should see a warning unless they're on node 22

This matches npm's current implementation of devEngines, as far as I'm aware.

However, there's an additional critically important scenario: CI.

One should be testing this hypothetical package on node 20 and 22+ (every major, or every minor, to the maintainer's preference). However, tests run npm install as if they were a developer of the package. Thus, CI runs that are on node 20 will see a warning (not that big a deal) or, fail the tests. That defeats the entire purpose of devEngines.

Current possible solutions:

  1. in CI, delete devEngines before the workflow run, and hope it doesn't get accidentally committed before you restore package.json
  2. in CI, overwrite devEngines.runtime.node with engines.node (and similarly for devEngines.packageManager.npm and engines.npm, etc) before the workflow run, and hope it doesn't get accidentally committed before you restore package.json

I'm planning to make a PR to npm to create a config setting (that can be set in .npmrc or by environment variable) that when enabled, will check the union of engines and devEngines (instead of just devEngines). Depending on how the npm team's feedback to that plays out, ofc, we should strive to communicate very clearly that such a mechanism is necessary - and that without such a mechanism, devEngines isn't worth implementing at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions