'Cloud function does not upload once googleapis are included
I have a google cloud functions project and once I include the googleapis to authorize to play developer api I cannot deploy the project anymore. This is the mwe:
import * as functions from 'firebase-functions';
import * as serviceAccountPlay from './service-account.json';
import { google } from 'googleapis';
export const realtimeNotificationListener =
functions.pubsub.topic('billing_information').onPublish(async (data, context) => {
//With this it does not deploy. Removing this deploys successfully
const authClient = new google.auth.JWT({
email: serviceAccountPlay.client_email,
key: serviceAccountPlay.private_key,
scopes: ["https://www.googleapis.com/auth/androidpublisher"]
})
const playDeveloperApiClient = google.androidpublisher({
version: 'v3',
auth: authClient}
);
const developerNotification = data.json;
console.log('Received realtime notification: ', developerNotification);
try {
const subscription = await playDeveloperApiClient.purchases.subscriptions.get({
packageName: developerNotification.packageName,
subscriptionId: developerNotification.subscriptionNotification!.subscriptionId,
token: developerNotification.subscriptionNotification!.purchaseToken
});
console.log('Received purchase information: ', subscription)
} catch (error) {
console.error(error);
}
})
I have this line in my package.json dependenies section: "googleapis":"^94.0.0"
I deployed using this command firebase --debug deploy --only functions:realtimeNotificationListener
The debug output is not very helpful:
[2022-02-01T11:57:02.767Z] Error: Failed to update function playSubBilling-realtimeNotificationListener in region us-central1 at C:\Users-\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:38:11 at runMicrotasks () at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Fabricator.updateV1Function (C:\Users-\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:255:32) at async Fabricator.updateEndpoint (C:\Users-\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:136:13) at async handle (C:\Users-\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\release\fabricator.js:75:17)
EDIT
After installing googleapis in the /functions folder I get a whole lot of other errors:
After npm i googleapis --save I get:
After npm audit fix I get:
And after firebase --debug deploy --only functions:realtimeNotificationListener I get:
What do I have to change to get this running again?
EDIT 2
Fixed it with
npm audit fix --force
and
npm update
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|



