Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force yarn to override yarn.lock version and install latest?

Tags:

yarnpkg

I would like to keep all other package versions in tact, but upgrade one single package to the most recent version. How can I do that using yarn?

I know I can delete yarn.lock, and then run yarn install, but I think that will upgrade every package, which I don't want. I just want the most recent version of node-sass, and for that to override the version I have in yarn.lock.

How can this be done?

like image 740
stevec Avatar asked Feb 01 '26 02:02

stevec


2 Answers

According to Yarn documentation:

yarn up [package]
yarn up [package]@[version]
yarn up [package]@[tag]

So, to upgrade node-sass, you should run:

yarn up node-sass
like image 57
Rodrigo Merlone Avatar answered Feb 03 '26 11:02

Rodrigo Merlone


The answer by Rodrigo Merlone does not work with yarn-classic. For yarn-classic, a resolution is required.

{
  "dependencies": {
    "left-pad": "1.0.0",
    "c": "file:../c-1",
    "d2": "file:../d2-1"
  },
  "resolutions": {
    "d2/left-pad": "1.1.1",
    "c/**/left-pad": "^1.1.2"
  }
}

More info: https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/

like image 42
Lucas Gonze Avatar answered Feb 03 '26 10:02

Lucas Gonze