首页 > 解决方案 > Vue CLI 和 Yarn 工作区

问题描述

是否可以在多包 Lerna 和 Yarn 工作区存储库中使用 Vue CLI(尤其是其插件)?我希望能够安装 Jest 插件并让它可用于我的所有软件包。

例如,这是我的根package.json

{
  ...
  "private": true,
  "workspaces": ["packages/*"],
  "scripts": {
    ...
    "test": "yarn workspaces run test"
  },
  ...
  "devDependencies": {
    ...
    "@vue/cli-plugin-babel": "^4.3.1",
    "@vue/cli-plugin-eslint": "^4.3.1",
    "@vue/cli-plugin-unit-jest": "^4.3.1",
    "@vue/cli-service": "^4.3.1",
    ... other dependencies installed by Vue CLI
  }
}

然后包装package.json

{
  ...,
  "scripts": {
    "test": "vue-cli-service test:unit",
    ...
  },
  ...
}

如果我yarn test在项目的根目录中运行,则会收到以下错误:

$ yarn workspaces run test
> my-package
$ vue-cli-service test:unit
ERROR command "test:unit" does not exist.
error Command failed with exit code 1.

有什么我想念的吗?或者这只是 Vue CLI 不支持?

标签: vue.jsyarnpkgvue-clilernayarn-workspaces

解决方案


推荐阅读