安装和升级pnpm
我建议你使用npm全局安装pnpm:
npm i -g pnpm要升级到最新版本,运行:
npm i -g pnpm@latest在你的shell中为pnpm添加别名
打开你的shell配置文件(例如.zprofile或.bash_profile):
$ code ~/.zprofile
# 或 code ~/.bash_profile或者如果你喜欢使用Vim:
$ vim ~/.zprofile
# 或 vim ~/.bash_profile在你的shell配置文件中添加以下行:
alias pn=pnpm然后重新加载配置:
source ~/.zprofile
# 或 source ~/.bash_profile现在你可以在shell中使用pn代替pnpm。
$ pn -v
9.12.1将项目依赖升级到最新版本
如果你想将项目中的所有依赖升级到最新版本,可以使用以下命令:
pnpm up -i -L这将显示将要升级的包列表,并询问你是否确认升级。
$ pn up -i -L
? Choose which packages to update (Press <space> to select, <a> to toggle all, <i> to invert selection) …
❯ ○ devDependencies
    ○ Package                                                    Current   Target
    ○ @commitlint/cli                                             19.4.1 ❯ 19.5.0
    ○ @commitlint/config-conventional                             19.4.1 ❯ 19.5.0
    ○ @types/node                                                 22.5.4 ❯ 22.7.5
    ○ @types/react                                                18.3.5 ❯ 18.3.11
    ○ @typescript-eslint/eslint-plugin                            6.21.0 ❯ 8.8.1
    ○ @typescript-eslint/parser                                   6.21.0 ❯ 8.8.1
    ○ eslint                                                      8.57.0 ❯ 9.12.0
    ○ eslint-config-next                                          14.2.8 ❯ 14.2.15
    ○ eslint-config-prettier                                      8.10.0 ❯ 9.1.0
    ○ husky                                                        9.1.5 ❯ 9.1.6
    ○ prettier-plugin-tailwindcss                                  0.6.6 ❯ 0.6.8
    ○ typescript                                                   5.5.4 ❯ 5.6.3
  ○ dependencies
    ○ Package                                                    Current   Target
    ○ @headlessui/react                                            2.1.5 ❯ 2.1.10
    ○ @next/bundle-analyzer                                       14.2.8 ❯ 14.2.15
    ○ contentlayer2                                                0.5.0 ❯ 0.5.1
    ○ esbuild                                                     0.23.1 ❯ 0.24.0
    ○ lucide-react                                               0.439.0 ❯ 0.451.0
    ○ next                                                        14.2.8 ❯ 14.2.15
    ○ next-contentlayer2                                           0.5.0 ❯ 0.5.1
    ○ pliny                                                        0.3.1 ❯ 0.3.2
    ○ postcss                                                     8.4.45 ❯ 8.4.47
    ○ rehype-citation                                              2.1.1 ❯ 2.2.0
    ○ rehype-preset-minify                                         7.0.0 ❯ 7.0.1
    ○ tailwindcss                                                 3.4.10 ❯ 3.4.13
 
Enter to start updating. Ctrl-c to cancel.愉快地使用别名!
