Skip to content
📦🐈 Fast, reliable, and secure dependency management.
Branch: master
Clone or download
alloy and cpojer feat(run): Add engines check before executing scripts. (#7021)
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/reaction@12.1.10: 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.
```
Latest commit 697a254 Mar 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Fixes Node 10 CI on OSX (#6580) Oct 25, 2018
.github Changelog workflow (#6460) Oct 2, 2018
__tests__ feat(audit): add filtering by severity level (#6716) Mar 17, 2019
bin Support Darwin bash in bin/yarn (#6568) Oct 23, 2018
end_to_end_tests Delete Docker container after test runs Nov 19, 2016
flow-typed/npm chore(jest): Upgrade Jest flow types (#5573) Mar 26, 2018
packages Check os and platform even when engines is not present in package.json ( Feb 1, 2019
resources Improve rendering of Chocolatey package description (#6899) Jan 14, 2019
scripts
src feat(run): Add engines check before executing scripts. (#7021) Mar 19, 2019
.babelrc Yarn Plug'n'Play: Implementation (#6382) Sep 24, 2018
.dockerignore Add Dockerfile for building Yarn (#2628) Feb 11, 2017
.editorconfig Allow token replacement of .npmrc configuration with env vars (#1207) Nov 14, 2016
.eslintignore chore(eslint): ignore packages dir (#4963) Nov 27, 2017
.eslintrc.json Fix generated .pnp.js compatibility with Node 6. (#6871) Jan 4, 2019
.flowconfig
.gitattributes Set tgz files as binary in git (#2273) Dec 16, 2016
.gitignore Yarn Plug'n'Play: Implementation (#6382) Sep 24, 2018
.npmignore Remove Roadrunner (#3079) Apr 8, 2017
CHANGELOG.md feat(run): Add engines check before executing scripts. (#7021) Mar 19, 2019
CODE_OF_CONDUCT.md
CONTRIBUTING.md docs(contributing): Direct contribution guides to the website (#4872) Nov 7, 2017
Dockerfile.dev fix: Add Node 10 support (#5769) May 23, 2018
LICENSE LICENSE: Specify BSD 2-Clause (#3133) May 12, 2017
README.md Add Azure Pipelines badge to README.md (#6720) Nov 26, 2018
appveyor.yml ci(perf): Set maxWorkers to match the number of cores available (#6249) Aug 9, 2018
azure-pipelines.yml Set up CI with Azure Pipelines (#6495) Nov 14, 2018
gulpfile.js Upgrade gulp v4 (#6143) Aug 22, 2018
jenkins_jobs.groovy
package.json 1.16.0-0 Mar 8, 2019
renovate.json Enable Renovate master issue approval (#6490) Oct 4, 2018
yarn.lock Fixing dynamic require missing from webpack (#6908) Jan 14, 2019

README.md

Yarn

Fast, reliable, and secure dependency management.

Circle Status Appveyor Status Azure Pipelines status Discord Chat Commitizen friendly


Fast: Yarn caches every package it has downloaded, so it never needs to download the same package again. It also does almost everything concurrently to maximize resource utilization. This means even faster installs.

Reliable: Using a detailed but concise lockfile format and a deterministic algorithm for install operations, Yarn is able to guarantee that any installation that works on one system will work exactly the same on another system.

Secure: Yarn uses checksums to verify the integrity of every installed package before its code is executed.

Features

  • Offline Mode. If you've installed a package before, then you can install it again without an internet connection.
  • Deterministic. The same dependencies will be installed in the same exact way on any machine, regardless of installation order.
  • Network Performance. Yarn efficiently queues requests and avoids request waterfalls in order to maximize network utilization.
  • Network Resilience. A single request that fails will not cause the entire installation to fail. Requests are automatically retried upon failure.
  • Flat Mode. Yarn resolves mismatched versions of dependencies to a single version to avoid creating duplicates.
  • More emojis. 🐈

Installing Yarn

Read the Installation Guide on our website for detailed instructions on how to install Yarn.

Using Yarn

Read the Usage Guide on our website for detailed instructions on how to use Yarn.

Contributing to Yarn

Contributions are always welcome, no matter how large or small. Substantial feature requests should be proposed as an RFC. Before contributing, please read the code of conduct.

See Contributing.

Prior art

Yarn wouldn't exist if it wasn't for excellent prior art. Yarn has been inspired by the following projects:

Credits

Thanks to Sam Holmes for donating the npm package name!

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.