Skip to content

Vite+ and corepack-like functionality #1309

Closed

Description

@rChaoz

Describe the bug

TL;DR Using Vite+ without an existing Node installation means no corepack, so any scripts/commands that try to run pnpm/yarn fail. Corepack can be installed, but will manage its own versions of pnpm/yarn, same as Vite+, leading to differences between running pnpm i and vp i.

Also, this is a little bit of a dupe of #858 (sorry, didn't see it before opening this 😞), but I think this issue better explains the problem & proposes a better solution.


I tried cloning the vite-plus repo according to the contribution guide with just init, and I've encountered some problems. I decided to document this here as I think it has some value regarding vp as a full-featured tool for everything JS-related, which seems to be its goal, and does very well at it too.

I'll start by saying that I removed nvm and associated global node installations first, to rely only on vp env. The issue described here is encountered by anyone that uses vp env for managing Node, without an existing node installation.

just init tries to run pnpm install, but fails with:

Error: Command failed: pnpm install --no-frozen-lockfile
'pnpm' is not recognized as an internal or external command, operable program or batch file.

Makes sense, since it downloaded a new node version. Normally, I'd enable corepack when I see this, but this doesn't work:

> corepack enable
corepack: The term 'corepack' is not recognized as a name of a cmdlet, function, script file, or executable program.
> npm list -g
C:\Users\Matei\.vite-plus\js_runtime\node\24.14.1
+-- corepack@0.34.6
`-- npm@11.11.0

Corepack is there, but Vite+ did not create a shim for it in ~/.vite-plus/bin. Vite+ does create shims for global packages, when using npm i -g or vp i -g. But since corepack comes preinstalled with node, this never happens.

Note: Both npm i -g and vp i -g, from my understanding, install a package globally, but for a specific node version. yarn ... will always run on the Node version I installed it with, not the dynamic Node version (based on .node-version or package.json#engines). It will remain stuck on whatever node version I happened to be using, which does depend on CWD, .node-version etc., forever. This seems like a potential design flaw, but I may be wrong, and regardless it's not related to the current issue. I thought it was worth pointing out, especially since it's not documented.

Continuing, the problem is that trying to call package managers directly, which relies on corepack, doesn't work out of the box. This includes vite-plus itself, as it runs pnpm directly. This can be fixed easily, however, by running:

vp i -g corepack

This works, but IMO is not "clean". Corepack now downloads and manages package manager versions independently of Vite+, so depending on whether you use vp add or pnpm add, a different installation (which may or may not be the same version) is used, as well as with a different node version.

My suggestions to address this, the first one being IMO the best:

  • Vite+ should implement corepack capabilities itself. It already does this when using vp i, vp add etc., which install and run the correct package manager and version automatically. The only piece missing is shimming the actual yarn, pnpm etc. executables by default.
  • If not, at least include some documentation on its environment page that corepack is not available by default, and vp install, vp add etc. should be used instead. However, I do think some people will be turned away by this - some people will simply not want to adjust their workflows (scripts, muscle memory) to use vp instead of pnpm.

If this is out of scope, and vp only wants to support managing package managers for its own commands, then:

  • Document on its environment page that corepack is not available by default, and that it should be installed with vp install -g corepack. Even as Node will no longer come with corepack by default from now on, this information would still be useful.
  • Automatically run vp install -g corepack when installing vp, or an equivalent.

Reproduction

  1. Make sure there is no global Node installation and you're only relying on vp env
  2. Try to clone/work on any repo which uses pnpm/yarn commands

Validations

Activity

  1. added theissue type on Apr 5, 2026
  2. fengmk2 commented on Apr 7, 2026

    @fengmk2
    Member

    #858 (comment) we can consider adding corepack to the default shims tool list. cc @cpojer

  3. cpojer commented on Apr 7, 2026

    @cpojer
    Member

    Yeah I think we should add the shim, until there is a proper alternative that everyone is happy to use.

  4. assigned and unassigned on Apr 7, 2026
  5. rChaoz commented on Apr 8, 2026

    @rChaoz
    ContributorAuthor

    Is there a reason why corepack would be added instead of adding shims for yarn, pnpm that simply call the vp pm equivalents?

  6. p-j commented on Apr 20, 2026

    @p-j

    vp pm doesn't support the yarn plugin ... commands, so it's not a full replacement to having access to the correct version of yarn for instance.

  7. fengmk2 commented on May 9, 2026

    @fengmk2
    Member

    @p-j follow up here #1539

  8. removed theissue type on May 9, 2026
  9. added this to the Beta milestone on May 20, 2026
  10. marked Shim for pnpm & yarn #858 as a duplicate of this issue on Jun 10, 2026
  11. sapphi-red commented on Jun 10, 2026

    @sapphi-red

    Using corepack would that mean the same pnpm version will be downloaded twice (one for corepack and one for viteplus), not a big deal though.

  12. fengmk2 commented on Jun 10, 2026

    @fengmk2
    Member

    @sapphi-red The double-install issue is currently unavoidable. If we choose to use corepack, then pnpm and yarn shims have to be managed by corepack. As users get used to the Vite+ Global CLI, we still hope everyone can use the vp command directly instead of pnpm. 😢

  13. added 3 commits that reference this issue on Jun 11, 2026
    ddc5a4a
    0d7d036
    b48e0a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions