Chocolatey 和 Scoop都是window下的软件包管理工具,用途同mac OS下的Homebrew
一 Chocolatey 的安装
1. 环境要求:
windows 7+ /windows server 2003+
Powershell v2+
-NET Framework 4+
$PSVersionTable.PSVersion.Major #查看Powershell版本 $PSVersionTable.CLRVersion.Major #查看.NET Framework版本
2. 安装:
以管理员身份打开powershell
使用PowerShell,您必须确保Get-ExecutionPolicy不受限制,建议使用Bypass绕过策略来安装东西或AllSigned提高安全性
查看策略
Get-ExecutionPolicy
如果返回Restricted, 需要先修改策略
Set-ExecutionPolicy AllSigned 或者 Set-ExecutionPolicy Bypass -Scope Process
会询问你是否要更改执行策略, 输入 Y 回车
安装
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
建议去[官网]([https://chocolatey.org/install](https://chocolatey.org/install)
)直接复制
等待几秒钟,命令完成, 如果没有看到任何错误,则可以使用Chocolatey!重启powershell 键入choco或choco -?
3. 使用Chocolatey安装yarn
choco install yarn
二、 Scoop的安装
1. 环境要求:
PowerShell 5.0或更高版本
查看powershell版本
$ psversiontable .psversion.major
2. 确保已允许PowerShell执行本地脚本,先设置 PowerShell 允许执行未签名脚本
set-executionpolicy remotesigned -scope currentuser
Unrestricted 也可以, 但是安全性比较低. 所以,如果你不是很确定就一直使用RemoteSigned
3. 下载 Scoop 安装脚本进行安装
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
或者使用
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
如果下载scoop的过程中断,那么必须先删除(C:Users<user>scoop)文件夹,再执行以上命令安装。
4. 使用
比如: 安装yarn
scoop install yarn