richardmyu / blog

个人(issues)博客
https://github.com/richardmyu/blog/issues
MIT License
0 stars 0 forks source link

windows 安装问题集合 #34

Open richardmyu opened 2 years ago

richardmyu commented 2 years ago

1.nvm use 异常

nvm 对应 windows 为 nvm-windows

nvm use 17.1.0
# exit status 1: �ܾ����ʡ�

1.安装目录 (C:\User\name\AppData\Roaming\nvm),这个路径看起来没问题,其实问题在 User,对中文用户,看到的不是 User,而是“用户”,安装目录出现中文,导致乱码。在修改这个路径后,我的就没有问题了。


设置 Node目录(默认 C:\Program Files\nodejs),要修改成没有空格;


到这里还是不够的,可以在 cmd 中正常使用 nvm,但在 powershell 无法使用,重启一下就好了。


2020-01-19

今天下载了 16.13.2 版本,切换失败。

➜ nvm use 16.13.2
exit status 1: You do not have sufficient privilege to perform this operation.

改用管理员权限再执行即可。

richardmyu commented 2 years ago

2.electron 安装

electron 国内镜像:https://npm.taobao.org/mirrors/electron/,安装的时候,会从 https://npm.taobao.org/mirrors/electron/v16.0.7/electron-v16.0.7-win32-x64.zip 获取,而实际 v16.0.7 在淘宝镜像中不存在,需要指定版本:npm install -D electron@16.0.6

richardmyu commented 2 years ago

3.Visual Studio 安装

今天安装 Visual Studio,下载好 exe 文件,点击后,需要在线安装 Installer,但是一直处于无法下载的状态。。。

根据参考文章找到系统日志(C:\Users\xx\AppData\Local\Temp\dd_bootstrapper_xxx):

VisualStudio Bootstrapper:2022/4/18 20:54:09: Beginning file download. File = https://aka.ms/vs/16/release/installer.
VisualStudio Bootstrapper:2022/4/18 20:54:09: Download requested: https://aka.ms/vs/16/release/installer
VisualStudio Bootstrapper:2022/4/18 20:54:09: Attempting download 'https://aka.ms/vs/16/release/installer' using engine 'WebClient'
VisualStudio Bootstrapper:2022/4/18 20:54:09: WebClient error 'ConnectionClosed' - proxy setting 'Default' - 'https://aka.ms/vs/16/release/installer'.
VisualStudio Bootstrapper:2022/4/18 20:54:09: WebClient failed in 'https://aka.ms/vs/16/release/installer' with '基础连接已经关闭: 连接被意外关闭。' - 'https://aka.ms/vs/16/release/installer'.
VisualStudio Bootstrapper:2022/4/18 20:54:09: Download failed using WebClient engine. System.Net.WebException: 基础连接已经关闭: 连接被意外关闭。
  ...
VisualStudio Bootstrapper:2022/4/18 20:54:09: Sleeping 5000 milliseconds before retrying download.
VisualStudio Bootstrapper:2022/4/18 20:54:14: Attempting download 'https://aka.ms/vs/16/release/installer' using engine 'Bits'
VisualStudio Bootstrapper:2022/4/18 20:55:06: Canceling job VsBitsDownloadJob - -960937641
VisualStudio Bootstrapper:2022/4/18 20:55:06: User Cancelled Download
VisualStudio Bootstrapper:2022/4/18 20:55:06: Bootstrapper cancelled.

可以看到,是链接 aka.ms 有问题,在浏览器出入地址,无法访问。根据参考文章的提示,在 C:\Windows\System32\drivers\etc\hosts 文件里添加 aka.ms 的映射,通过 ip查询网址 获得 IP 地址,写入 hosts:

104.71.153.3 aka.ms

然后确实成功安装了。


在其他文章中,看到有人类似的操作无法成功,但是能通过修改默认 DNS 服务器为 114.114.114.114 或 8.8.8.8 成功安装。有人分析是域名解析错误,使用 nsloolup aka.ms 得到 127.0.0.1。我尝试了一下,获得如下数据:

# 第一次
> nslookup aka.ms
Server:  aka.ms
Address:  88.221.62.148

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
*** Request to aka.ms timed-out

# 第二次
> nslookup aka.ms
Server:  aka.ms
Address:  104.95.74.223

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
*** Request to aka.ms timed-out

可以看到我本地的问题不是域名污染,而是链接超时。但如果在 hosts 文件建立 aka.ms 的映射,文件可以下载,但 nslookup 测试结果同上:

> nslookup 104.71.153.3
Server:  [104.71.153.3]
Address:  104.71.153.3

DNS request timed out.
    timeout was 2 seconds.
DNS request timed out.
    timeout was 2 seconds.
*** Request to 104.71.153.3 timed-out

再看到有些文章提问 aka 无法访问的问题,也提到污染,可以使用 8.8.4.4 或 4.4.4.4。


参考:

安装Visual Studio,Installer无法下载(已解决)

richardmyu commented 1 year ago

4.PSReadLine 修改颜色

# v7.2+
$ISETheme = @{
    Command                  = $PSStyle.Foreground.FromRGB(0x0000FF)
    Comment                  = $PSStyle.Foreground.FromRGB(0x006400)
    ContinuationPrompt       = $PSStyle.Foreground.FromRGB(0x0000FF)
    Default                  = $PSStyle.Foreground.FromRGB(0x0000FF)
    Emphasis                 = $PSStyle.Foreground.FromRGB(0x287BF0)
    Error                    = $PSStyle.Foreground.FromRGB(0xE50000)
    InlinePrediction         = $PSStyle.Foreground.FromRGB(0x93A1A1)
    Keyword                  = $PSStyle.Foreground.FromRGB(0x00008b)
    ListPrediction           = $PSStyle.Foreground.FromRGB(0x06DE00)
    Member                   = $PSStyle.Foreground.FromRGB(0x000000)
    Number                   = $PSStyle.Foreground.FromRGB(0x800080)
    Operator                 = $PSStyle.Foreground.FromRGB(0x757575)
    Parameter                = $PSStyle.Foreground.FromRGB(0x000080)
    String                   = $PSStyle.Foreground.FromRGB(0x8b0000)
    Type                     = $PSStyle.Foreground.FromRGB(0x008080)
    Variable                 = $PSStyle.Foreground.FromRGB(0xff4500)
    ListPredictionSelected   = $PSStyle.Background.FromRGB(0x93A1A1)
    Selection                = $PSStyle.Background.FromRGB(0x00BFFF)
}

Set-PSReadLineOption -Colors $ISETheme

# v7.1
# Set foreground and background colors
Set-PSReadLineOption -Colors @{ "Comment"="`e[32;47m" }

# Set multiple options
$PSReadLineOptions=@{
    Colors=@{
        "Command" = "#0000FF"
        "Comment" = "#006400"
    "ContinuationPrompt" = "#0000FF"
    "Default" = "#0000FF"
    "Emphasis" = "#287BF0"
    "Error" = "#E50000"
    "InlinePrediction" = "#93A1A1"
    "Keyword" = "#00008b"
    "ListPrediction" = "#06DE00"
    "Member" = "#000000"
    "Number" = "#800080"
    "Operator" = "#757575"
    "Parameter" = "#000080"
    "String" = "#8b0000"
    "Type" = "#008080"
    "Variable" = "#ff4500"
    "ListPredictionSelected" = "#93A1A1"
    "Selection" = "#00BFFF"
    }
}
Set-PSReadLineOption @PSReadLineOptions

参考: 配置浅色主题 powershell - 更改 PowerShell PSReadLine MenuComplete 函数的颜色 Set-PSReadLineOption