Node.js/yarn:修订间差异
来自康健生活
| 第6行: | 第6行: | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
curl -o- -L https://yarnpkg.com/install.sh | bash</syntaxhighlight>}} | curl -o- -L https://yarnpkg.com/install.sh | bash</syntaxhighlight>}} | ||
== 源 == | |||
查询当前使用的镜像源 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
yarn config get registry</syntaxhighlight>|$|/home/kangkk}} | |||
设置源 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
yarn config set registry <registry-url> | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
{| class="wikitable" | |||
|- | |||
| 淘宝镜像源 || https://registry.npmmirror.com/ | |||
|- | |||
| 腾讯云镜像源 || https://mirrors.cloud.tencent.com/npm/ | |||
|- | |||
| 官方镜像源 || https://registry.yarnpkg.com/ | |||
|} | |||
== 配置文件 == | |||
== 添加 == | |||
指定版本号 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
yarn add package-name # 安装最新版本 | |||
yarn add package-name@0.0.1 # 安装指定版本 | |||
yarn add package-name@tag # 安装指定标识版本 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
指定路径 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
yarn add package-name # 指定配置源安装,也可 package.json 指定源安装 | |||
yarn add file:/path/to/local/folder # 指定本地文件系统里安装,可用这种方式来测试还未发布的包 | |||
yarn add file:/path/to/local/tarball.tgz # 指定本地文件系统里安装压缩包 | |||
yarn add <git remote url> # 指定远程 git repo 安装 | |||
yarn add <git remote url> # 指定远程 git repo 安装,可指定 git <branch/commit/tag> | |||
yarn add https://x.y/package.tgz # 指定远程 gzipped 压缩包安装。 | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
== 更新依赖 == | == 更新依赖 == | ||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
yarn upgrade-interactive --latest</syntaxhighlight>|$}} | yarn upgrade-interactive --latest</syntaxhighlight>|$}} | ||