For AI agents: the complete documentation index is available at /docs/llms.txt, the full documentation bundle is available at /docs/llms-full.txt, and this page is available as Markdown at /docs/env/dev/language/npm.md.
  • 简体中文
  • 2026
  • 前端

    安装 node

    mac 或 linux 下安装 nvm

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
    nvm -v

    安装node

    ## 列出远程可用版本
    nvm ls-remote --lts
    ## 安装最新 LTS 版本
    nvm install --lts
    ## 安装指定代号的 LTS(lts/krypton 代表 node 24)
    nvm install lts/krypton
    ## 设置默认版本
    nvm alias default lts/krypton
    ## 手动切换版本
    nvm use 18
    node -v

    配置镜像源:

    npm config set registry https://registry.npmjs.org
    npm config get registry

    安装包管理工具

    • npm。node自带,无序安装
    • pnpm
    • Yarn

    安装 pnpm

    curl -fsSL https://get.pnpm.io/install.sh | sh -
    pnpm -v

    配置代理

    新建 .npmrc 文件,文件内容如下:

    registry=https://registry.npmmirror.com/