1、設置鏡像源
npm install cnpm -g --registry=https://registry.npm.taobao.org
yarn config set registry https://registry.npm.taobao.org/
把C:\Users\ 用戶名\AppData\Roaming\npm目錄加入系統環境變量Path,然后重啟即可。
cnpm 和yarn都可能會有以下提示:
yarn : File C:\Users\xxy\AppData\Roaming\npm\yarn.ps1 cannot be loaded because running scripts is disabled on this system. For more information
PowerShell yarn : 無法加載文件 C:\Users\Admin\AppData\Roaming\npm\yarn.ps1,因為在此系統因為在此系統上禁止運行腳本。
以管理員方式運行powershell
2:使用命令更改計算機的執行策略
PS C:\Users\Administrator> set-ExecutionPolicy RemoteSigned
執行策略更改
執行策略可幫助你防止執行不信任的腳本。更改執行策略可能會產生安全風險,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 幫助主題所述。是否要更改執行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暫停(S) [?] 幫助 (默認值為“N”): y
3:查看執行策略
get-ExecutionPolicy