DEV Community

Yue
Yue

Posted on

yipm: All-in-One Package Management Command

There are now multiple package management tools for front-end projects, including npm, yarn, pnpm, and the newly introduced bun. They were developed in different contexts, each with its own strengths and weaknesses, and all are commonly used in real-world projects. During development, it is often necessary to use the corresponding commands, and when working on multiple projects simultaneously, you need to confirm which tool is being used before executing a command. For pnpm, in particular, there have been significant version changes over time, requiring additional verification of the pnpm version in use.

yipm provides a set of concise commands that can automatically identify the package manager used in the current project and execute the corresponding commands. It is a tool that improves efficiency while reducing mental load.

Principle

It identifies the package manager by detecting lock files—for example, package-lock.json indicates npm, yarn.lock indicates yarn, and so on. Additionally, it supports the package manager specified in the packageManager property of package.json (see packageManager).

Installation

npm i -g yipm@latest
Enter fullscreen mode Exit fullscreen mode

Usage

yipm shortens commonly used commands. For instance, entering yy executes npm install, and entering yys executes npm install && npm run start. The actual package manager used is automatically identified based on the project. This eliminates the need to remember lengthy commands or manually determine which package manager a project uses.

The table below shows the mapping between yipm commands and various package manager commands.

yipm command npm yarn pnpm bun
ypm npm yarn pnpm bun
yy npm install yarn pnpm install bun install
yys npm i && npm start yarn && yarn start pnpm i && pnpm start bun i && bun run start
yyd npm i && npm run dev yarn && yarn dev pnpm i && pnpm dev bun i && bun run dev
yyb npm i && npm run build yarn && yarn build pnpm i && pnpm build bun i && bun run build
ya <pkg> npm install <pkg> yarn add <pkg> pnpm add <pkg> bun add <pkg>
yad <pkg> npm install -D <pkg> yarn add -D <pkg> pnpm add -D <pkg> bun add -D <pkg>
yb npm run build yarn build pnpm build bun run build
yd npm run dev yarn dev pnpm dev bun run dev
yr <script> npm run <script> yarn run <script> pnpm run <script> bun run <script>
yrm <pkg> npm uninstall <pkg> yarn remove <pkg> pnpm remove <pkg> bun remove <pkg>
ys npm run start yarn start pnpm start bun run start
yt npm run test yarn test pnpm test bun run test
ylk npm link yarn link pnpm link --global bun link

Simple Mnemonics for Common Commands

  • Install dependencies — yy
  • Run dev script — yd
  • Install and run dev script — yyd
  • Run build script — yb
  • Install and run build script — yyb

This allows you to quickly get a new project up and running using commands of no more than three letters.

Top comments (0)