This error happened after I update firebase-functions and firebase-admin
"firebase-functions": "^2.0.4",
"firebase-admin": "^6.0.0"
Full Error
Error: Error occurred while parsing your function triggers.
Error: Failed to import the Cloud Firestore client library for Node.js. Make sure to install the "#google-cloud/firestore" npm package. Original error: Error: Cannot find module 'protobufjs/minimal'
This is all dependencies I have
"axios": "^0.18.0",
"compose-middleware": "^4.0.0",
"cors": "^2.8.4",
"cuid": "^1.3.8",
"exponent-server-sdk": "^2.3.1",
"express": "^4.15.4",
"firebase": "^4.13.1",
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.4",
"lodash": "^4.17.4",
"moment": "^2.22.2",
"query-string": "^6.1.0"
Maybe roll back to v5/v1? All you should need is below for cloud functions and firestore interactions.
var admin = require('firebase-admin');
var functions = require('firebase-functions');
Below is what my package.json shows, and my stuff works fine:
"firebase-admin": "^5.12.0",
"firebase-functions": "^1.0.2",
how about installing the missing protobufjs package with npm install or npm update ... maybe even explicitly add "protobufjs": "^6.8.8" - or install it with npm install protobufjs?
Related
I was following the in-app-purchase part in Google Codelab, But after I finish all steps and finally run firebase deploy this error has appeared.
I have read many solutions about the simillar problems, for example, remove node-modules and package-lock file then re-install them, down grade node version to 14, downgrade firebase-admin, firebase-functions...
But none of them works for me.
I'm totally desperate now. Please somebody help me. I already googled almost 72hours and I found nothing.
And here is the contents of terminal show up after I run firebase deploy.
% firebase deploy
=== Deploying to 'server-259035'...
i deploying firestore, functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint /Users/functions
> eslint --ext .js,.ts .
Running command: npm --prefix "$RESOURCE_DIR" run build
> functions# build /Users/functions
> tsc
✔ functions: Finished running predeploy script.
i firestore: reading indexes from firestore.indexes.json...
i cloud.firestore: checking firestore.rules for compilation errors...
✔ cloud.firestore: rules file firestore.rules compiled successfully
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudfunctions.googleapis.com is enabled
✔ functions: required API cloudbuild.googleapis.com is enabled
i functions: preparing codebase default for deployment
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/firestore' is not defined by "exports" in /Users/functions/node_modules/firebase-admin/package.json
And package.json file.
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"watch": "tsc --watch",
"serve": "firebase emulators:start",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "lib/index.js",
"dependencies": {
"camelcase-keys": "^8.0.0",
"firebase-admin": "^11.0.1",
"firebase-functions": "^3.22.0",
"google-auth-library": "^8.0.2",
"googleapis": "^105.0.0",
"jest": "^28.1.3",
"lodash": "^4.17.21",
"node-apple-receipt-verify": "^1.12.1"
},
"devDependencies": {
"#types/node-apple-receipt-verify": "^1.7.1",
"#typescript-eslint/eslint-plugin": "^5.27.0",
"#typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.26.0",
"firebase-functions-test": "^2.3.0",
"typescript": "^4.7.2"
},
"private": true
}
I had the same issue when updated my package.json packages. I had to make the following change in order to fix it:
Before:
import firestore from "firebase-admin/lib/firestore";
After:
import firebaseAdmin from "firebase-admin";
** Add the prefix firebaseAdmin. to all the firestore references, eg: firebaseAdmin.firestore.Timestamp;*
I changed the following files:
app-store.purchase-handler.ts
google-play.purchase-handler.ts
iap.repository.ts
It happens with in_app_purchases flutter firebase example due to updated package names and their content. Full error is: Error: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/firestore' is not defined by "exports" in functions/node_modules/firebase-admin/package.json
You need to replace: import firestore from "firebase-admin/lib/firestore"; with import firebaseAdmin from "firebase-admin";
Now you need to go your .ts files and replace the same import above with the new one and correct the references for example: firestore.Timestamp now will be firebaseAdmin.firestore.Timestamp
All the files you need to make changes are these ones:
app-store.purchase-handler.ts
google-play.purchase-handler.ts
iap.repository.ts
I’ve fixed, upgraded and updated codelab example backend functions for verifying in app purcashe on backend. You can find updated code here, it works as expected for me with node 18.
https://github.com/vbalagovic/iap-firebase-backend
I'm developing an app using Expo, using the Firebase JS SDK (https://docs.expo.io/guides/using-firebase/), only for Authentication and to use the Cloud Firestore Database. It works fine on browser but when I switch to Expo Go I get this error:
ReferenceError: Can't find variable: IDBIndex
It's my understanding that the Firebase SDK should work fine aside from when using Analytics, which I'm not using. I have spent hours googling this issue but most people refer to an issue with Analytics, so any help would be really appreciated!
My package.json:
"dependencies": {
"#react-native-community/masked-view": "0.1.10",
"#react-navigation/native": "^5.9.4",
"#react-navigation/stack": "^5.14.4",
"expo": "~41.0.0",
"expo-status-bar": "~1.0.4",
"firebase": "8.2.3",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
"react-native-datefield": "^0.1.0",
"react-native-gesture-handler": "~1.10.2",
"react-native-reanimated": "~2.1.0",
"react-native-safe-area-context": "3.2.0",
"react-native-screens": "~3.0.0",
"react-native-web": "~0.13.12"
},
"devDependencies": {
"#babel/core": "^7.9.0"
}
I fixed this issue by using firebase#9.1.0. In the expo docs they mention that they are using this version in their example. https://docs.expo.dev/guides/using-firebase/
With newer versions of Firebase I encounter the same issue.
I have tried to find similar problem in stackoverflow but no one can solve my issue.
I am trying to test my firebase security rules, using Typescript and Mocha, but I can't even run my test
here is my project directory
I install my dev dependecies using this code:
npm install chai mocha ts-node #types/chai #types/mocha --save-dev
here is my dev dependecies
"devDependencies": {
"#firebase/rules-unit-testing": "^1.2.5",
"#types/chai": "^4.2.15",
"#types/mocha": "^8.2.2",
"#types/uuid": "^8.3.0",
"#typescript-eslint/eslint-plugin": "^3.9.1",
"#typescript-eslint/parser": "^3.8.0",
"chai": "^4.3.4",
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.22.0",
"mocha": "^8.3.2",
"ts-node": "^9.1.1",
"typescript": "^3.9.9"
},
and here is my script npm
"scripts": {
"test": "mocha --exit"
},
but when run npm run test , from functions directory I have error
Error: No test files found: "test"
I have tried using
mocha --require ts-node/register --watch-extensions ts 'test/**/*.ts'
I still have the same error. what should I do?
I finally can run the test using
mocha -r ts-node/register src/**/*.test.ts --timeout 60000 --exit
don't forget to install ts-node as dev dependecy and please note that the file name should be in format
myFileName.test.ts
Upon trying to update my pods to the latest in order to work with IOS 12.0 I keep getting this error. I've seen this error pretty well documented online but none of the current solutions I have found seem to work.
In Podfile:
RNFBApp (from `../node_modules/#react-native-firebase/app`) was resolved to 10.5.0, which depends on
Firebase/CoreOnly (~> 7.4.0)
RNFBAuth (from `../node_modules/#react-native-firebase/auth`) was resolved to 10.5.1, which depends on
Firebase/Auth (~> 7.4.0) was resolved to 7.4.0, which depends on
Firebase/CoreOnly (= 7.4.0)
react-native-camera/BarcodeDetectorMLKit (from `../node_modules/react-native-camera`) was resolved to 3.42.0, which depends on
Firebase/MLVisionBarcodeModel was resolved to 5.0.0, which depends on
Firebase/CoreOnly (= 5.0.0)
As far as pod install --repo-update and pod update etc I keep returning to this error. I've updated my dependancies manually in the package.json file to the latest and removed the pod.lock file. I've run a react native clean across it to ensure all cache files are cleaned and tried to reinstalling everything and still getting the error.
I'm sure I'm missing something that I either need to wipe somewhere but can't find where exactly I need to do this.
Here's my Pod file
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '12.0'
target 'shoppinStore' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'shoppinStoreTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'shoppinStore-tvOS' do
# Pods for shoppinStore-tvOS
target 'shoppinStore-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
# add the Firebase pod for Google Analytics
pod 'Firebase/Analytics'
# add pods for any other desired Firebase products
# https://firebase.google.com/docs/ios/setup#available-pods
pod 'react-native-camera', path: '../node_modules/react-native-camera', subspecs: [
'BarcodeDetectorMLKit'
]
And my Package.json
"name": "shoppinStore",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/checkbox": "^0.5.7",
"#react-native-community/geolocation": "^2.0.2",
"#react-native-community/masked-view": "^0.1.10",
"#react-native-firebase/app": "^10.5.0",
"#react-native-firebase/auth": "^10.5.1",
"#react-native-firebase/firestore": "^10.5.1",
"#react-navigation/bottom-tabs": "^5.11.3",
"#react-navigation/native": "^5.9.0",
"#react-navigation/stack": "^5.13.0",
"firebase": "^8.2.3",
"react": "16.13.1",
"react-native": "0.63.4",
"react-native-camera": "^3.42.0",
"react-native-gesture-handler": "^1.9.0",
"react-native-reanimated": "^1.13.2",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.16.1",
"react-navigation": "^4.4.3",
"react-redux": "^7.2.2",
"redux": "^4.0.5"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/runtime": "^7.8.4",
"#react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
I'm pretty new to React Native, this all happened after chasing errors trying to connect my phone to test the app to get the React Native Camera library to work. Not the project won't build at all. Any pointers will be greatly appreciative.
I had this problem due to M1 chip.
I deleted Pods folder
Deleted PodFile.lock
For M1 chip :
1. Install ffi
sudo arch -x86_64 gem install ffi
2. Re-install dependencies
arch -x86_64 pod install
I was getting this also so I updated my firebase packages in package.json, deleted podfile.lock in the ios folder, and ran pod repo update, then pod install.
Worked after that! Good luck!
I using expo 3.27.10 and node v12.18.4 below is package info I tried to install firebase using expo and npm both fails then how I initialize firebase config file
firebase.initializeApp(firebaseConfig);
firebase.analytics();
and package.json is
"dependencies": {
"#react-native-community/masked-view": "0.1.10",
"#react-native-firebase/analytics": "^7.6.4",
"#react-native-firebase/app": "^8.4.3",
"#react-native-firebase/auth": "^9.2.3",
"#react-navigation/native": "^5.7.4",
"#react-navigation/stack": "^5.9.1",
"expo": "~39.0.2",
"expo-status-bar": "~1.0.2",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-39.0.2.tar.gz",
"react-native-gesture-handler": "~1.7.0",
"react-native-reanimated": "~1.13.0",
"react-native-safe-area-context": "3.1.4",
"react-native-screens": "~2.10.1",
"react-native-web": "~0.13.12",
"firebase": "7.9.0"
},
For me I have to change node version current 14.13 to LTS 12.18 and this allows me to install firebase
If: expo install firebase
isn't work for you and you got an Error,
That maybe you are having an old npm version uou need to update your npm
npm update
Or you got error for installation that because FIREBASE made update so to fix it use
yarn add firebase
see more: https://www.npmjs.com/package/firebase
I had a similar issue. What I did:
- remove firebase from the package.json.
- npm update
- npm install
- npm install --save firebase
afterwards had to change import * as firebase from 'firebase' to
import firebase from 'firebase'
if(firebase.apps.length === 0){
firebase.initializeApp(firebaseConfig)
}
p.s: working with VSCode, node v14.15.1, firebase 8.2.7
Downloading 2019 visual studio tools solved the error for me. You can scroll down and download only 2019 tools if you don't Want Visual Studio.
Click the link to download here