使用 VS Code智能提示功能之 typings
使用步骤
————————————————
版权声明:本文为优快云博主「天马3798」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/u011127019/article/details/56671511
- 安装命令
npm install -g typings
- 查看typings的版本
typings --version
- 初始化
typings init
这时当前目录下会出现一个typings.json的文件
- 安装对应插件的提示工具
typings install dt~node --global --save
typings install dt~express --global
typings install dt~lodash --global
- 常用命令:
# 安装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>
解决办法
.typingsrc
方法
- 不成功
- 修改
hosts
文件参考:https://newsn.net/say/raw-githubusercontent-com.html
- 利用
chinaz
的ping功能,查找合适的ip:- chinaz: http://ping.chinaz.com/raw.githubusercontent.com
- 打开
hosts
文件,把IP粘贴:
- 成功,出现了一个
ytpings
文件