使用 Chocolatey 安装 Yarn

使用 Chocolatey 安装 Yarn 是一个非常简单的过程。以下是详细的步骤:

步骤 1:确保已经安装了 Chocolatey

使用 Windows PowerShell (管理员) 安装 Chocolatey:https://blog.csdn.net/m0_65152767/article/details/143783103?spm=1001.2014.3001.5502

步骤 2:使用 Chocolatey 安装 Yarn

  1. 打开 PowerShell 作为管理员

    • Win + X 键。
    • 选择 Windows PowerShell (管理员)Windows Terminal (管理员)
  2. 运行安装命令

    choco install yarn
    
    Windows PowerShell
    版权所有 (C) Microsoft Corporation。保留所有权利。
    
    尝试新的跨平台 PowerShell https://aka.ms/pscore6
    
    PS C:\WINDOWS\system32> choco install yarn
    Chocolatey v2.4.0
    Installing the following packages:
    yarn
    By installing, you accept licenses for the packages.
    Downloading package from source 'https://community.chocolatey.org/api/v2/'
    Progress: Downloading yarn 1.22.22... 100%
    
    yarn v1.22.22 [Approved]
    yarn package files install completed. Performing other installation steps.
    The package yarn wants to run 'chocolateyinstall.ps1'.
    Note: If you don't run this script, the installation will fail.
    Note: To confirm automatically next time, use '-y' or consider:
    choco feature enable -n allowGlobalConfirmation
    Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): y
    
    Using system proxy server '127.0.0.1:7890'.
    Downloading yarn
      from 'https://yarnpkg.com/downloads/1.22.22/yarn-1.22.22.msi'
    Using system proxy server '127.0.0.1:7890'.
    Progress: 100% - Completed download of C:\Users\dgq\AppData\Local\Temp\chocolatey\yarn\1.22.22\yarn-1.22.22.msi (1.59 MB).
    Download of yarn-1.22.22.msi (1.59 MB) completed.
    Hashes match.
    Installing yarn...
    yarn has been installed.
    0
      yarn may be able to be automatically uninstalled.
    Environment Vars (like PATH) have changed. Close/reopen your shell to
     see the changes (or in powershell/cmd.exe just type `refreshenv`).
     The install of yarn was successful.
      Software installed as 'msi', install location is likely default.
    
    Chocolatey installed 1/1 packages.
     See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
    
    Did you know the proceeds of Pro (and some proceeds from other
     licensed editions) go into bettering the community infrastructure?
     Your support ensures an active community, keeps Chocolatey tip-top,
     plus it nets you some awesome features!
     https://chocolatey.org/compare
    
  3. 等待安装完成

    • 安装过程可能需要几分钟时间,耐心等待。
  4. 验证安装

    • 运行以下命令来验证 Yarn 是否安装成功:
      yarn --version
      
    • 如果安装成功,你会看到 Yarn 的版本号。

示例步骤

以下是完整的示例步骤:

  1. 确保已经安装了 Chocolatey

    • 打开 PowerShell 作为管理员。
    • 运行以下命令:
      choco -v
      
    • 如果输出显示 Chocolatey 的版本号,说明 Chocolatey 已经安装成功。
  2. 使用 Chocolatey 安装 Yarn

    • 打开 PowerShell 作为管理员。
    • 运行以下命令:
      choco install yarn
      
  3. 等待安装完成

    • 安装过程可能需要几分钟时间,耐心等待。
  4. 验证安装

    • 运行以下命令:

      yarn --version
      
      PS C:\WINDOWS\system32> yarn --version
      1.22.22
      PS C:\WINDOWS\system32>
      
    • 如果安装成功,你会看到 Yarn 的版本号。

其他注意事项

C:\Users\dgq>where yarn
D:\Java\node-v16.13.2-win-x64\node-v16.13.2-win-x64\yarn
D:\Java\node-v16.13.2-win-x64\node-v16.13.2-win-x64\yarn.cmd
C:\Program Files (x86)\Yarn\bin\yarn
C:\Program Files (x86)\Yarn\bin\yarn.cmd
C:\Program Files (x86)\Yarn\bin\yarn.js
  1. 确保 PATH 环境变量正确配置

    • 如果你遇到 yarn 命令无法识别的问题,可以手动检查和修改 PATH 环境变量。
    • 打开“系统属性” -> “高级” -> “环境变量”,在“系统变量”部分找到 Path 变量,确保包含 Yarn 的安装路径(通常是 C:\ProgramData\chocolatey\bin)。
  2. 重新启动命令提示符或 PowerShell

    • 安装完成后,建议重新启动命令提示符或 PowerShell 以确保所有环境变量更新生效。

通过以上步骤,你应该能够成功使用 Chocolatey 安装 Yarn 并验证安装是否成功。

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值