30
  • You can do yarn add my-package to install the latest version of my-package
  • You can do yarn add [email protected] to install v1.2.3

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

1 Answer 1

54

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 
Sign up to request clarification or add additional context in comments.

3 Comments

It doesn't for me. Yarn installs the exact given version and adds it to package.json without the ^. E.g., yarn add express@^4.15.4 ends up with "express": "4.15.4";.
Works for me if I put quotes around the dependency, as in yarn add "express@^4.15.4"

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.