Skip to content

Check engines before running scripts #7013

@alloy

Description

@alloy

I want to request a feature, if it doesn’t exist yet.

I wasn’t able to find this in the yarn run docs nor a previous issue asking about this, if I missed it please point me at the right direction.

I would like yarn to check the engines specified in the package.json manifest file before executing any scripts through yarn run (or just yarn). In my case I’m specifically interested in ensuring my team all invoke scripts using the same Node version.

We already have a program that checks the Node version and some of our scripts invoke that before doing their actual work, however:

  • It's easy to add a script and forget to prefix it with our verification program.
  • It doesn’t help the cases where people invoke a program directly without there being a script entry in the package.json file. E.g. they might invoke yarn jest directly, instead of yarn test.

What is the current behavior?

Yarn will run scripts without complaining when engine requirements do not match the current env.

What is the expected behavior?

I would like yarn to complain. E.g.

$ yarn jest
The current environment does not satisfy the engine "node" requirements. Expected version "10.13.*".
$ nvm use 10.13
Now using node v10.13.0
$ yarn jest
yarn run v1.12.3
/Users/eloy/Code/Artsy/metaphysics/node_modules/.bin/jest
[…]

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions