Skip to content

docs: improve devEngines note #1535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/cli/v10/configuring-npm/package-json.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ The `devEngines` field aids engineers working on a codebase to all be using the

You can specify a `devEngines` property in your `package.json` which will run before `install`, `ci`, and `run` commands.

> Note: `engines` and `devEngines` differ in object shape. They also function very differently. `engines` is designed to alert the user when a dependency uses a differening npm or node version that the project it's being used in, whereas `devEngines` is used to alert people interacting with the source code of a project.
> Note: `engines` and `devEngines` differ in object shape and functionality. `engines` is designed to alert the user when a dependency uses a different npm or node version than the project it's being used in, whereas `devEngines` is used to alert people interacting with the source code of a project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn’t quite accurate - engines is for a package to declare what npm and/or node versions it’s compatible with.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting to get rid of the word alert or something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Note: `engines` and `devEngines` differ in object shape and functionality. `engines` is designed to alert the user when a dependency uses a different npm or node version than the project it's being used in, whereas `devEngines` is used to alert people interacting with the source code of a project.
> Note: `engines` and `devEngines` differ in object shape and functionality. `engines` is intended for a package to declare the node and/or npm versions it is compatible with (the default for both is `*`), whereas `devEngines` is used to declare the intended runtime (node, etc) and/or package manager (npm, etc) to be used by developers working directly in the source code of a project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think I see what you're saying now 👍

What do you think of e012ff6?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's certainly correct! It would be nice to have the nuance that's contained in my suggestion, though :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styfle I like the nuance from @ljharb as well. If you want to update it with that I can see about getting this merged :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Please take a look at ffbb248

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. The part about the default value is documented elsewhere, so it doesn't need to be here, but it seemed useful to reinforce.

Copy link
Contributor Author

@styfle styfle Apr 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I left out the default value is because this section of the docs is about devEngines, not engines.

We should keep the NOTE short(ish) or else move it out of the NOTE and into a normal paragraph.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.


The supported keys under the `devEngines` property are `cpu`, `os`, `libc`, `runtime`, and `packageManager`. Each property can be an object or an array of objects. Objects must contain `name`, and optionally can specify `version`, and `onFail`. `onFail` can be `warn`, `error`, or `ignore`, and if left undefined is of the same value as `error`. `npm` will assume that you're running with `node`. Here's an example of a project that will fail if the environment is not `node` and `npm`. If you set `runtime.name` or `packageManager.name` to any other string, it will fail within the npm CLI.

Expand Down
2 changes: 1 addition & 1 deletion content/cli/v11/configuring-npm/package-json.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ The `devEngines` field aids engineers working on a codebase to all be using the

You can specify a `devEngines` property in your `package.json` which will run before `install`, `ci`, and `run` commands.

> Note: `engines` and `devEngines` differ in object shape. They also function very differently. `engines` is designed to alert the user when a dependency uses a differening npm or node version that the project it's being used in, whereas `devEngines` is used to alert people interacting with the source code of a project.
> Note: `engines` and `devEngines` differ in object shape and functionality. `engines` is designed to alert the user when a dependency uses a different npm or node version than the project it's being used in, whereas `devEngines` is used to alert people interacting with the source code of a project.

The supported keys under the `devEngines` property are `cpu`, `os`, `libc`, `runtime`, and `packageManager`. Each property can be an object or an array of objects. Objects must contain `name`, and optionally can specify `version`, and `onFail`. `onFail` can be `warn`, `error`, or `ignore`, and if left undefined is of the same value as `error`. `npm` will assume that you're running with `node`. Here's an example of a project that will fail if the environment is not `node` and `npm`. If you set `runtime.name` or `packageManager.name` to any other string, it will fail within the npm CLI.

Expand Down