这些node包管理器的常用命令

tools 24-05-2024

整理npm、yarn和pnpm的常见命令,方便查阅。

初始化

npm init
yarn init
pnpm init

安装

安装所有依赖

npm install
yarn
pnpm install

安装指定版本

npm install <package-name>@<version>  // example: npm install express@1.x
yarn add <package-name>@<version>  // example: yarn add react@^17.0.2
pnpm add <package-name>@<version> // example: pnpm add typescript@3.9.6

更新

更新所有依赖

npm update
pnpm up

更新指定包到指定版本

npm update <package-name>@<version> // example: npm update express@latest
yarn upgrade <package-name>@<version> // example: yarn upgrade react@next
pnpm up <package-name>@<version> // example: pnpm up @types/react@latest

删除

npm uninstall <package-name> // or
npm remove <package-name>
yarn remove <package-name>
pnpm uninstall <package-name> // or
pnpm un <package-name> // or
pnpm rm <package-name>
Author's photo

FindingKim

A web developer

See other articles:

undefinedThumbnail

MD Kitchen Sink

Here at Qode Interactive, we believe typography should be approached with equal focus and care as any other design element. It’s not just that the fonts “carry” the text, they also imbue the design with particular psychological values and convey specific

dev 30-06-2023