打字稿给出,“找不到模块 'xmlhttprequest' 的声明文件." [英] Typescript gives, "Could not find a declaration file for module 'xmlhttprequest'."

查看:75
本文介绍了打字稿给出,“找不到模块 'xmlhttprequest' 的声明文件."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用,

import { XMLHttpRequest } from 'xmlhttprequest';

在 Node 上使用 tsc

On Node I get the following error when I compile with tsc

index.ts|4 col 32 错误|7016[QF 可用]:找不到模块xmlhttprequest"的声明文件.'/node_modules/xmlhttprequest/lib/XMLHttpRequest.js' 隐含地具有 'any' 类型.尝试 npm install @types/xmlhttprequest 如果它存在或添加一个包含 declare module 'xmlhttprequest'; 的新声明 (.d.ts) 文件

index.ts|4 col 32 error| 7016[QF available]: Could not find a declaration file for module 'xmlhttprequest'. '<project>/node_modules/xmlhttprequest/lib/XMLHttpRequest.js' implicitly has an 'any' type. Try npm install @types/xmlhttprequest if it exists or add a new declaration (.d.ts) file containing declare module 'xmlhttprequest';

然而,那个包裹似乎不在那里,

However, that package doesn't seem to be there,

npm install @types/xmlhttprequest
npm ERR! code E404
npm ERR! 404 Not Found: @types/xmlhttprequest@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ecarroll/.npm/_logs/2018-07-31T00_19_20_299Z-debug.log

有没有办法打包这种类型的东西?

Is there a way anything that packages this type?

推荐答案

您可以尝试在命令行中执行 npm install @types/xmlhttprequest --save.

Can you try to do npm install @types/xmlhttprequest --save in your command line.

如果报错,说明xmlhttprequest库不支持TypeScript.

If it gives you error, then it means that xmlhttprequest library does not support TypeScript.

这篇关于打字稿给出,“找不到模块 'xmlhttprequest' 的声明文件."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆