yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.37k stars 2.72k forks source link

Why does `yarn install` modifyed `package.json` #9006

Open cipchk opened 8 months ago

cipchk commented 8 months ago

For example:

{
  "name": "test",
  "packageManager": "yarn@4.0.1",
  "dependencies": {
    "typescript": "~5.1.3",
    "ts-node": "~10.9.1"
  }
}

After executing yarn install, package.json will be modified to:

{
  "name": "test",
  "packageManager": "yarn@4.0.1",
  "dependencies": {
-    "typescript": "~5.1.3",
-    "ts-node": "~10.9.1"
+    "ts-node": "~10.9.1",
+    "typescript": "~5.1.3"
  }
}

Although working for me, it is very useful for us to keep the original order in some environments.

edub008 commented 5 months ago

The install algorithm is most likely re-arranging them based on alphabetical order.