Vue-cli: Vue add doesn't work when using Yarn Workspaces

Created on 3 Oct 2018  Â·  7Comments  Â·  Source: vuejs/vue-cli

Version

3.0.4

Node and OS info

Node v10.11.0, Yarn 1.9.4

Steps to reproduce

In an existing project using the package.json field vuePlugins with a Yarn workspace like so...

"vuePlugins": {
    "resolveFrom": "someWorkspace"
  }

Run the command

vue add @vue/typescript

What is expected?

That the vue plugin is installed and the generator is invoked.

What is actually happening?

This error

📦  Installing @vue/cli-plugin-typescript...

yarn add v1.9.4
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
 ERROR  command failed: yarn add -D @vue/cli-plugin-typescript

It should be noted that I also get similar errors when manually installing the required dependancies for the Vue-CLI plugin but when using a Yarn Workspace the vue invoke command also fails.

needs reproduction

Most helpful comment

Hi @LinusBorg Sorry this took so long but here is a repo for reproduction. You can just clone this run yarn then run vue add @vue/cli-plugin-typescript

You should get:

📦  Installing @vue/cli-plugin-typescript...

yarn add v1.9.4
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
 ERROR  command failed: yarn add -D @vue/cli-plugin-typescript

Sorry for the wait but thanks for taking a look at this.

I should mention that the .yarnrc fix does work, but I think it should probably be built into VueCLI or at least in the VueCLI docs alongside resolveFrom.

All 7 comments

is the vue-cli project itself in a workspace?

It would really be helpful if you could provide a demo repository.

Use .yarnrc
--add.ignore-workspace-root-check true

quick start:
vue add @o3o/packages

See: https://github.com/Aircity/vue-cli-plugin-packages

Seems to be resolved by @Aircity 's comment, and OP is inactive. Closing for now.

Hi @LinusBorg Sorry this took so long but here is a repo for reproduction. You can just clone this run yarn then run vue add @vue/cli-plugin-typescript

You should get:

📦  Installing @vue/cli-plugin-typescript...

yarn add v1.9.4
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it explicit by running this command again with the -W flag (or --ignore-workspace-root-check).
 ERROR  command failed: yarn add -D @vue/cli-plugin-typescript

Sorry for the wait but thanks for taking a look at this.

I should mention that the .yarnrc fix does work, but I think it should probably be built into VueCLI or at least in the VueCLI docs alongside resolveFrom.

I added .yarnrc in my user folder and my project root, and I still get this issue

C:\Projects\scratch\frontend (develop -> origin) 
λ vue add eslint
�  Installing @vue/cli-plugin-eslint...

yarn add v1.19.2
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Running this command will add the dependency to the workspace root rather than the workspace itself, which might not be what you want - if you really meant it, make it e
xplicit by running this command again with the -W flag (or --ignore-workspace-root-check).
 ERROR  command failed: yarn add @vue/cli-plugin-eslint -D --registry=https://registry.yarnpkg.com

Adding my two cents in case it helps anyone else out:

I was running into a similar issue. Turns out one of my other packages was using a newer version of typescript which caused @vue/cli-plugin-typescript and typescript to be installed into my package's node_modules instead of the root one. I set both of my packages to use a compatible typescript version and the error went away.

Having a monorepo setup here.

I am using yarn workspaces. vue add eslint ran in the package folder tries to use npm but I want it to use yarn...

vue add eslint in the root folder gives me the same error error Running this command will add the dependency to the workspace.

I don't want to install it into the root, in want to run vue add ... inside the package folder..

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sanderswang picture sanderswang  Â·  3Comments

PrimozRome picture PrimozRome  Â·  3Comments

BusyHe picture BusyHe  Â·  3Comments

DrSensor picture DrSensor  Â·  3Comments

OmgImAlexis picture OmgImAlexis  Â·  3Comments