typings ~报错

使用 VS Code智能提示功能之 typings

使用步骤

————————————————
版权声明:本文为优快云博主「天马3798」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/u011127019/article/details/56671511

  1. 安装命令
npm install -g typings
  1. 查看typings的版本
typings --version
  1. 初始化
typings init

这时当前目录下会出现一个typings.json的文件

  1. 安装对应插件的提示工具
typings install dt~node --global --save
typings install dt~express --global
typings install dt~lodash --global
  1. 常用命令:
# 安装Typings的命令行代码. 
npm install typings --global

# 搜索对应模块的typings定义. 
typings search tape

# 根据名称寻找一个可获得的typings定义. 
typings search --name react

# 如果你用一个独立包的模块: 
# 或者并不是安装全局模块
# 比如并不是在命令行通过输入npm install -g typings这种方式安装的. 
typings install debug --save

# 如果是通过script标记
# 或者是子环境的一部分
# 或者全局typings命令不可用的时候: 
typings install dt~mocha --global --save

# 从其他版本处安装typings定义(比如env或者npm). 
typings install env~atom --global --save
typings install npm~bluebird --save

# 使用该文件`typings/index.d.ts` (在`tsconfig.json`文件使用或者用 `///` 定义). 
cat typings/index.d.ts

报错内容

typings ERR! message Unable to connect to "https://raw.githubusercontent.com/Def
initelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index
.d.ts"
typings ERR! caused by getaddrinfo ENOENT raw.githubusercontent.com
typings ERR!
typings ERR! cwd C:\Users\user\Desktop\Embedded\rewi_blog\vuepress-rewi
typings ERR! system Windows_NT 10.0.19043
typings ERR! command "D:\\nodejs\\node.exe" "C:\\Users\\user\\AppData\\Roaming\\
npm\\node_modules\\typings\\dist\\bin.js" "install" "dt~node" "--global" "--save
"
typings ERR! node -v v14.17.6
typings ERR! typings -v 2.1.1
typings ERR! code EUNAVAILABLE
typings ERR!
typings ERR! If you need help, you may report this error at:
typings ERR!   <https://github.com/typings/typings/issues>

解决办法

  1. .typingsrc 方法
  • 不成功
  1. 修改hosts文件

    参考:https://newsn.net/say/raw-githubusercontent-com.html

  • 利用 chinaz的ping功能,查找合适的ip:
    • chinaz: http://ping.chinaz.com/raw.githubusercontent.com

在这里插入图片描述

  • 打开hosts文件,把IP粘贴:
    在这里插入图片描述
  • 成功,出现了一个ytpings文件
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值