Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

yarnpkg

  • 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?

like image 344
Tom Avatar asked Nov 24 '19 18:11

Tom


People also ask

How do I install a specific version dependency yarn?

Installing Options Installing all dependencies: yarn or yarn install. Installing one and only one version of a package: yarn install --flat. Forcing a re-download of all packages: yarn install --force. Installing only production dependencies: yarn install --production.

Can I use yarn add instead of npm install?

When other people start using Yarn instead of npm , the yarn. lock file will ensure that they get precisely the same dependencies as you have. In most cases, running yarn or yarn add for the first time will just work.

Does yarn install add dev dependencies?

yarn install is used to install all dependencies for a project. This is most commonly used when you have just checked out code for a project, or when another developer on the project has added a new dependency that you need to pick up.


1 Answers

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
like image 160
Tom Avatar answered Sep 18 '22 06:09

Tom