nodejs / nodejs/corepack

`corepack project install` command?

Open
#505 4 comments 11 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
279
Avg merge
1h 47m
Merged PRs (30d)
2

Description

Currently, there's no standardized way to install dependencies for projects using different package managers without prior knowledge of the specific manager used. This can complicate CI/CD pipelines, development scripts, and workflows for developers working across multiple projects.

It would be nice to be able to write a script that will do npm install / pnpm install / yarn install on arbitrary packages, without having to know in advance what their packageManager field says.

Proposal - a --project parameter added to the install command:

corepack install --project

This would change install to install the project/node_modules rather than the package manager itself. (Or could be a separate command or something).

For a project with "packageManager": "pnpm@9.4.0" the corepack install --project command would be equivalent to running

corepack enable
pnpm install

(called via a subshell)

Or for a project with "packageManager": "npm@10.1.0" this would be equivalent to

corepack enable
npm install

Similar for yarn, etc.

Benefits

  • Simplifies shared code for CI/CD pipelines like GitHub Actions
  • Reduces boilerplate in build scripts
  • Improves developer experience when working with multiple projects

Other notes:

  • could/should probably have a fallback behaviour when no packageManager is present, of using npm, or looking for lockfiles, or just erroring
  • potential follow-on: allow passing extra args after a -- like corepack install --project -- --no-frozend-lockfile (though this would no longer really be generic across package managers I guess)
  • potential follow-on: similar install-package functionality like corepack add left-pad

Not sure if this has been asked before but I couldn't find it in the issues.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing install command and how the packageManager field is read. Define the project-install behavior, fallback when the field is absent, and argument handling; done requires an agreed interface and behavior for npm, pnpm, and yarn.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
cli, developer-experience
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.