首页 > 解决方案 > vscode中Windows 10中的node.js安装错误

问题描述

Exception calling "DownloadString" with "1" argument(s): "The request was aborted: Could not create SSL/TLS secure
channel."
At line:1 char:1
+ iex ((New-Object System.Net.WebClient).DownloadString('https://chocol ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : WebException
choco : The term 'choco' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:95
+ ... .DownloadString('https://chocolatey.org/install.ps1')); choco upgrade ...
+                                                             ~~~~~
    + CategoryInfo          : ObjectNotFound: (choco:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException*

标签: javascripthtmlnode.jschocolatey

解决方案


您正在尝试在未启用 TLS 1.2 的情况下安装 Chocolatey。有关这方面的更多信息,请参阅此博客文章

以下内容直接取自该博客文章:

虽然您的操作系统可能支持 TLS 1.2,但重要的是要记住它可能必须启用。如果您使用 PowerShell 工作,您可以通过运行以下代码来了解您的系统支持哪些协议:

[Enum]::GetNames([Net.SecurityProtocolType]) -contains 'Tls12'

如果结果为 True,则您的系统支持 TLS 1.2。您可以通过运行找出正在使用的协议:

[System.Net.ServicePointManager]::SecurityProtocol.HasFlag([Net.SecurityProtocolType]::Tls12)

如果结果为 True,则使用 TLS 1.2。但是,您可以使用以下命令显式添加 TLS 1.2:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12

推荐阅读