npm / npm/rfcs

[RRFC] allowing to use engines as config variable

Open
#769 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
777
Forks
267
PR merge metrics
No merged PRs in 30d

Description

Motivation ("The Why")

package.json allows us to use engines where we can limit node version.

In CI/CD we often use the pattern when we clone some projects and try to run some tasks from it which requires npm install.

Let's say our pipeline also can accept some parameter such as node version but at the same time we want to enforce a certain rule, when node verrsion of that image should match some version condition.

Currently it is also possible to enforce node version check by use of engines parameter directly in our package.json ( or indirectly via dependent packages ). However let's say if we want to run npm install as it would have something like engines: { node: >20 } we need to set it manually or at least via npm pkg set engines.node which will modify package.json and it's not perfect for CI/CD procedures where upstream project ideally should stay not touched.

I thought if we would have an option to run something like:

npm_config_engines_node='>=18.8` npm i

which would enforce engine check as it's declared in package.json
then we could enforce engine from command line

What do you think of this?

Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked npm package.json engines documentation and compare it with how npm install currently interprets the engines field. Examine the proposed npm_config_engines_node command in CI/CD scenarios; done means the RFC has a clear, accepted behavior for enforcing a command-line engine constraint without modifying package.json.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.