Force users to use
yarninstead ofnpm.
If run from npm instead of yarn, the process will exit with error code 1
and print an error message.
Note: this will not work if used with npm install --save-dev --ignore-scripts.
Note: Use with >= yarn@1 requires >= use-yarn@2.
For example, in your package.json:
{
  "scripts": {
     "preinstall": "use-yarn || ( npm install --save-dev --no-scripts --no-save use-yarn && use-yarn )"
  }
}Or if you're on npm >=5 or have npx:
{
  "scripts": {
     "preinstall": "npx use-yarn"
  }
}You may provide a custom message via the -m flag:
{
  "scripts": {
     "preinstall": "npx use-yarn -m 'Please use yarn!'"
  }
}
Or, you may also provide a custom message read from a file via the -f flag:
{
  "scripts": {
     "preinstall": "npx use-yarn -f path/to/customMessage.txt"
  }
}
You may disable use-yarn by setting the DISABLE_USE_YARN environment variable to true:
{
  "scripts": {
     "preinstall": "DISABLE_USE_YARN=true npx use-yarn"
  }
}
var useYarn = require('use-yarn')
useYarn()
// or a custom message
useYarn('You idiot!')If you want to catch missed updates to yarn.lock on CI, try danger-yarn-lock.