I was able to reproduce the error and brute force of the solution. I donβt know much about npm and cannot give a full explanation of why this solution worked.
My original package.json contains:
"dependencies": { ... "firebase-admin": "^4.2.1", "firebase-functions": "^0.7.1", ... },
As recommended in the documentation , I ran these two commands in the functions folder:
npm install -g firebase-tools npm install firebase-functions@latest --save
I also tried:
npm install --save firebase-admin npm upgrade
I have repeatedly received these error messages:
+-- UNMET PEER DEPENDENCY firebase-admin@4.2.1 npm WARN firebase-functions@0.7.1 requires a peer of firebase-admin@ ~5.4.2 but none was installed.
I decided that firebase-admin needed to be updated, but could not. So I edited the dependency file to remove this line:
"firebase-admin": "^4.2.1"
then ran npm install --save firebase-admin again. At the same time, package.json contained the version of "firebase-admin": "^5.4.2" and var db = admin.firestore(); compiled without errors.
Bob snyder
source share