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
.
Then I tried to import it using import * as tools from 'firebase-tools';
, but I get this error:
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';
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.
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
.
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.
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"
Thank you for reading.
The way I solved this problem was:
First of all, add "firebase-tools": "^9.10.0"
to your package.json
under /functions
directory, like so:
"dependencies": {
...
"firebase-admin": "^9.2.0",
"firebase-functions": "^3.13.1",
"firebase-tools": "^9.10.0"
},
Then, in your function code use require
instead of import
, like so:
const firebase_tools = require('firebase-tools');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With