nuxt/cli

`pnpm env` Support

Closed this issue · 2 comments

It seems the new CLI uses Corepack to manage the package managers, however if the user is using pnpm env to manage their node install, pnpm will disable Corepack as to not be accidentally overridden, thus throwing CLI errors.

See https://pnpm.io/installation#using-corepack & pnpm/pnpm#4029 for further info.

Terminal Logs from nuxi init

❯ pnpm dlx nuxi@latest init ./
../../.pnpm-store/v3/tmp/dlx-50064       |   +1 +
../../.pnpm-store/v3/tmp/dlx-50064       | Progress: resolved 2, reused 0, downloaded 1, added 1, done

✔ Which package manager would you like to use?
pnpm
◐ Installing dependencies... 
'corepack' is not recognized as an internal or external command,
operable program or batch file.

ERROR  Error: Command failed with exit code 1: corepack pnpm install

ERROR  Command failed with exit code 1: nuxi init ./

pnpm: Command failed with exit code 1: nuxi init ./
    at makeError (C:\snapshot\dist\pnpm.cjs)
    at handlePromise (C:\snapshot\dist\pnpm.cjs)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.handler [as dlx] (C:\snapshot\dist\pnpm.cjs)
    at async C:\snapshot\dist\pnpm.cjs
    at async main (C:\snapshot\dist\pnpm.cjs)
    at async runPnpm (C:\snapshot\dist\pnpm.cjs)
    at async C:\snapshot\dist\pnpm.cjs```

My team is facing the same issue as we all use pnpm env for managing our Node.js installations too. The issue also exists on other environments too which lack Corepack, such as using via CLI in StackBlitz's terminal (aware of Nuxt templates, only wanted to test).

A workaround for now is using --no-install and installing manually.

pnpm dlx nuxi@latest init --no-install <project-name>
cd <project-name>
pnpm install
pi0 commented

Hi. In latest version (3.8.2), we have added a fallback mechanism for when corepack is not available directly using local env's pnpm. Let me know if still having issues to investigate 👍🏼