vue icon indicating copy to clipboard operation
vue copied to clipboard

vue-template-compiler `"vue": "file:../.."` devDependency breaks installs in yarn "workspaces" environments.

Open broofa opened this issue 2 years ago • 0 comments

Version

2.7.14

Reproduction link

https://github.com/vuejs/vue/blob/dev/packages/vue-template-compiler/package.json#L29

Steps to reproduce

(Apologies for not providing an actual SSCCE here. I'm hoping this is an obvious enough, "That ain't right!" issue that an actual reproduction case isn't needed. If it is, let me know and I'll put something together.)

What is expected?

The vue dependency should be a normal version string (e.g. Maybe "2.x")

What is actually happening?

It's... not.

Unfortunately, this causes problems with package manager tools like yarn. For example, I stumbled upon this issue because we're using Yarn workspaces. We have one workspace ("vue-2") that depends on vue@2 and another ("vue-3") that depends on vue@3. Normally, yarn install would be smart enough to keep the module trees separate. However, because of the non-standard dependency declaration here, yarn hoists vue-template-compiler into node_modules at the project root alongside the vue@3 dependencies. So when vue-template-compiler tries to load, it pulls in the wrong version of vue.

FWIW (and as a breadcrumb for others who may have this issue), the solution was to add a nohoist directive to the workspaces section of our project's package.json file.

"workspaces":
    "nohoist": [
      "vue-2/vue-template-compiler"
    ],
   "packages": [
      "vue-2",
      "vue-3",
      // ...
    ]
}


Cc @ktsn and @yyx990803 : It looks like this dependency declaration was added in #7918. (commit here since that PR doesn't seem to want to show actual files or commits)

broofa avatar Dec 14 '22 19:12 broofa