找不到模块"firebase-tools"的声明文件 [英] Could not find a declaration file for module 'firebase-tools'

查看:74
本文介绍了找不到模块"firebase-tools"的声明文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Firebase编写我的第一个云函数,它需要 firebase-tools 模块.我通过将其添加到package.json文件的依赖项中并运行 npm install 来安装它.

I am writing my first cloud function for Firebase and it requires the firebase-tools module. I've installing it by adding it to my dependencies in the package.json file and running npm install.

然后我尝试使用 import *作为'firebase-tools'中的工具导入它; ,但出现此错误:

Then I tried to import it using import * as tools from 'firebase-tools';, but I get this error:

找不到模块"firebase-tools"的声明文件.'c:/Users/LENOVO/Nouveau dossier/functions/node_modules/firebase-tools/lib/index.js'隐式具有"any"类型.如果存在,请尝试 npm install @ types/firebase-tools 或添加一个包含`declare module'firebase-tools';

Could not find a declaration file for module 'firebase-tools'. 'c:/Users/LENOVO/Nouveau dossier/functions/node_modules/firebase-tools/lib/index.js' implicitly has an 'any' type. Try npm install @types/firebase-tools if it exists or add a new declaration (.d.ts) file containing `declare module 'firebase-tools';

我也尝试运行 npm install @ types/firebase-tools ,但是显然它不存在,因此我不确定应该在(.d.ts)文件中放入什么模块.

I also tried running npm install @types/firebase-tools, but apparently it does not exist and I'm not sure what I should put in the (.d.ts) file for this module.

因此,我问是否还有其他解决方案,是否需要创建(.d.ts)文件,应在 declare module'firebase-tools .

So I'm asking if there's another solution and if I need to create a (.d.ts) file what should I put there beside declare module 'firebase-tools.

推荐答案

我也有同样的问题.问题是firebase-tools模块没有(.d.ts)文件.我发现在这种情况下,我们有3种解决方案.

I have same problem, too. The problem is that firebase-tools modules don't have (.d.ts)file. I found that we have 3 solutions in this situation.

  • 安装@ types/xxx←您已经完成了,但是不存在.
  • 自制(.d.ts)文件←我不太清楚.
  • 使用"require"代替"import"←我解决了这个问题.模块是隐式导入为"any"类型.

当ts-lint提醒您"[tslint]要求语句不是导入语句的一部分(no-var-requires)"时,可以通过注释"//tslint:disable-next-line:no-var"将其忽略-需要"

when ts-lint alert you "[tslint] require statement not part of an import statement (no-var-requires)", you can ignore it by comment "// tslint:disable-next-line:no-var-requires"

感谢您的阅读.

这篇关于找不到模块"firebase-tools"的声明文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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