Skip to content

CLI cannot bootstrap under PnP #4531

Closed
Closed
@arcanis

Description

@arcanis

Version

3.11.0

Environment info

Environment Info:

  System:
    OS: macOS 10.14.5
    CPU: (8) x64 Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
  Binaries:
    Node: 12.3.1 - ~/.nodenv/shims/node
    Yarn: 1.17.2 - ~/.nodenv/shims/yarn
    npm: 6.11.1 - ~/.nodenv/shims/npm
  Browsers:
    Chrome: 76.0.3809.132
    Firefox: Not Found
    Safari: 12.1.1
  npmGlobalPackages:
    @vue/cli: 3.11.0

Steps to reproduce

Note: requires #4530

  • Clone the Yarn 2 repository (https://github.com/yarnpkg/berry)
  • Run yarn build:cli inside it
  • Go to /tmp
  • Run PATH="~/path/to/berry/scripts/bin:$PATH" yarn dlx -p @vue/cli vue create vue-cli-yarn2
  • Go to /tmp/vue-cli-yarn2
  • Check the package.json

What is expected?

The package.json should contain all the information.

What is actually happening?

It only contains the devDependencies to the generators; the generators didn't run.


This is caused by resolveModule failing to find the packages, which is caused by the @vue/cli context not having access to the project dependencies. Since the CLI and the project are in different dependency trees, they cannot be loaded in the same context without creating many ambiguities (since they share the same underlying files, a package file could ambiguously depend on two different versions of a single package depending on the dependency tree they are supposed to be part of).

The fix would be to call the generators from within the project dependencies - for example, CRA does that by adding to the project dependencies a package exporting a binary called react-scripts which, when called, calls its own generator. The global CRA then just have to call the binary (using execa), and everything works.

Ref yarnpkg/berry#368

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions