警告:无法找到模块存储库

问题描述 投票:6回答:3

我试图在激活的Windows Server 2016标准上安装Docker。我执行了“Install-Module -Name DockerMsftProvider -Repository PSGallery -Force”但失败了。它建议找不到PSGallery。我执行了"Get-PSRepository"。错误:

警告:无法找到模块存储库。

我用谷歌搜索了3种解决方法,但没有用。

  1. 我成功地执行了Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Verbose -Force
  2. 我成功安装了巧克力。
  3. 我执行"powershell Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted"但失败了。它让我使用"Register-PSRepository -Default"

我试过"powershell Register-PSRepository -Default -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted"但仍然失败了。我怎么能解决这个问题?

docker windows-server-2016
3个回答
3
投票

简单地运行Register-PSRepository -Default(没有任何其他参数)为我工作。之后,Gallery成功注册:

PS C:\Windows\system32> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2/

1
投票

我的问题是缺少代理配置

评论的最佳解决方案:https://www.zerrouki.com/working-behind-a-proxy/ 感谢@Vadzim


在PowerShell中打开Profile

PS> notepad $PROFILE

这将打开记事本与您的配置文件设置,将创建不存在。 然后加:

[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://webproxy.yourCompany.com:PORT')
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true

不知怎的,我的本地代理已设置但不起作用。以后在Docker中遇到同样的问题,=>

> PS> [Environment]::SetEnvironmentVariable("HTTP_PROXY", http://username:password@proxy:port/", [EnvironmentVariableTarget]::Machine)

然后重启docker服务


0
投票

我收到了类似的消息。我运行了“Register-PSRepository -default”并且注册正常。然后我运行了Set-PSRepository -Name PSGallery -InstallationPolicy Trusted。我没有合并命令,但它有效。

我花了一个多小时尝试将凭据传递给代理,就像我在Exchange Online中一样,但没有爱。我断开连接并使用我们的访客WiFi。

© www.soinside.com 2019 - 2024. All rights reserved.