-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Check engines before running scripts #7013
Labels
Comments
It sounds good. I can handle it if there is nobody else working on it. |
@oguzzkilic I'd love to PR it myself, actually. I know what needs to happen, just wanted to bring it up first :) |
PR'ed #7021 |
alloy
added a commit
to alloy/yarn
that referenced
this issue
Feb 11, 2019
cpojer
pushed a commit
that referenced
this issue
Mar 19, 2019
Closes #7013 **Summary** A more elaborate description is available in #7013. In short, ensuring scripts are ran in the expected environment can deter hard to diagnose bugs. **Test plan** Given a `node` engine requirement that doesn’t match the current environment: ``` $ cat package.json | grep -i1 '"node"' "engines": { "node": "^10.13.0" }, $ nvm use 8 Now using node v8.12.0 (npm v6.4.1) ``` A script invocation will fail as follows: ``` $ node ~/Code/JavaScript/yarn/lib/cli/index.js run relay yarn run v1.15.0-0 error @artsy/[email protected]: The engine "node" is incompatible with this module. Expected version "^10.13.0". Got "8.12.0" error Commands cannot run with an incompatible environment. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` If need be, this can be overridden with the `--ignore-engines` flag: ``` $ node ~/Code/JavaScript/yarn/lib/cli/index.js run --ignore-engines relay yarn run v1.15.0-0 $ relay-compiler --src ./src --schema data/schema.graphql --language typescript --artifactDirectory ./src/__generated__ --exclude '**/node_modules/**,**/__mocks__/**,**/__generated__/**' ✨ Done in 2.22s. ``` Or, of course, making the environment match the requirements: ``` $ nvm use 10.13 Now using node v10.13.0 (npm v6.4.1) $ node ~/Code/JavaScript/yarn/lib/cli/index.js run relay yarn run v1.15.0-0 $ relay-compiler --src ./src --schema data/schema.graphql --language typescript --artifactDirectory ./src/__generated__ --exclude '**/node_modules/**,**/__mocks__/**,**/__generated__/**' ✨ Done in 1.91s. ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 thepackage.json
manifest file before executing any scripts throughyarn run
(or justyarn
). 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:
package.json
file. E.g. they might invokeyarn jest
directly, instead ofyarn 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.
The text was updated successfully, but these errors were encountered: