I need to delete field in Firestore Document in my react app, Firebase documentation mentioned that I should use FieldValue from 'firebase-admin':
// Get the `FieldValue` object
var FieldValue = require("firebase-admin").firestore.FieldValue;
but when I'm trying to get the FieldValue object like this, I get an error:
TypeError: existsSync is not a function
./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js/exports.find
I also saw some warnings in my console:
./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 16:20-67 Critical dependency: the request of a dependency is an expression
./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js 16:20-67 Critical dependency: the request of a dependency is an expression
./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 19:22-48 Critical dependency: the request of a dependency is an expression
./node_modules/google-gax/node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js 19:22-48 Critical dependency: the request of a dependency is an expression
./node_modules/google-gax/node_modules/grpc/src/grpc_extension.js 30:14-35 Critical dependency: the request of a dependency is an expression
what could be the problem here?
The firebase-admin node module is made for use in server-side node processes. You're trying to use it in a client-side React app, which is not going to work.
In client-side React you should use the regular Firebase JavaScript/Web SDK and use the code snippet from that tab in the docs:
var cityRef = db.collection('cities').doc('BJ'); // Remove the 'capital' field from the document var removeCapital = cityRef.update({ capital: firebase.firestore.FieldValue.delete() });