Skip to content

[RRFC] allowing to use engines as config variable #769

@ThePlenkov

Description

@ThePlenkov

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!

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