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