Search code examples
yarnpkg

Is it possible to specify a version range when using `yarn add`?


  • You can do yarn add my-package to install the latest version of my-package
  • You can do yarn add my-package@1.2.3 to install v1.2.3

Can you specify a range, like in package.json?


Solution

  • Yes.

    I don't know why this isn't documented explicitly, but this works:

    yarn add "express@^4.15.4"
    # wrote "express": "^4.15.4" to package.json
    # actually installed v4.17.1, which is latest satisfactory version