首页 新闻 会员 周边 捐助

怎么一劳永逸地用typings设置好vscode上nodejs的代码提示?

0
悬赏园豆:10 [已关闭问题] 关闭于 2021-01-14 18:05

最近用VSCODE学习nodejs的操作,但是发现每次写require,读写流之类的关键字都没有相关方法提示就很蛋疼,上网查到了介绍typings设置代码提示的文章,但是当按文章介绍用npm安装好typings,在项目目录行设置好

typings init
typings install dt~node --global --save

后,发现弹出了错误:

复制代码
node:11224) UnhandledPromiseRejectionWarning: PopsicleError: Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index.d.ts"
    at Request.error (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\request.js:41:16)
    at ClientRequest.<anonymous> (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\index.js:131:39)   
    at ClientRequest.emit (events.js:327:22)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:11224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_reject| Compiling "node"
(node:11224) UnhandledPromiseRejectionWarning: PopsicleError: Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index.d.ts"
    at Request.error (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\request.js:41:16)
    at ClientRequest.<anonymous> (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\index.js:131:39)   
    at ClientRequest.emit (events.js:327:22)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:11224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_reject| Compiling "node"
(node:11224) UnhandledPromiseRejectionWarning: PopsicleError: Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index.d.ts"
    at Request.error (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\request.js:41:16)
    at ClientRequest.<anonymous> (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\index.js:131:39)   
    at ClientRequest.emit (events.js:327:22)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:11224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on un| Compiling "node"
(node:11224) UnhandledPromiseRejectionWarning: PopsicleError: Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index.d.ts"
    at Request.error (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\request.js:41:16)
    at ClientRequest.<anonymous> (C:\Users\hw\AppData\Roaming\npm\node_modules\typings\node_modules\popsicle\dist\index.js:131:39)   
    at ClientRequest.emit (events.js:327:22)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:11224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejecttypings ERR! message Unable to connect to "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/a4a912a0cd1849fa7df0e5d909c8625fba04e49d/node/index.d.ts"
typings ERR! caused by read ECONNRESET
typings ERR!
typings ERR! cwd E:\myprogramming\Javascript\NodeJS\NODEJS入门教程
typings ERR! system Windows_NT 10.0.18363
typings ERR! command "D:\\nodejs\\node.exe" "C:\\Users\\hw\\AppData\\Roaming\\npm\\node_modules\\typings\\dist\\bin.js" "install" "dt~node" "--global" "--save"
typings ERR! node -v v12.18.3
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>
复制代码

不知是我代理的问题还是多文件冲突的问题。

想去相关github上报issue,但是typings的issues早就已经archive了,也没能从一堆英语问题中找到和自己相似的情况。

直接在项目文件夹下打

npm install --save @types/node

倒是成功了,但是我不想每次新建一个文件夹的时候都要打一遍指令,让文件夹都粘着一个模组扩展。

 

不知各位博友可有什么解决方法?

另一种开始的主页 另一种开始 | 初学一级 | 园豆:119
提问于:2021-01-13 21:21
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册