question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to deploy functions with Typescript

See original GitHub issue

Version info

firebase-functions: 2.1.0

firebase-tools: 6.1.2

firebase-admin: 6.4.0

Test case

When using Typescript together with firebase functions I’m unable to deploy any code because of the following error:

Error: mod.hasOwnProperty is not a function

Typescript version: 3.2.2

Steps to reproduce

functions/index.ts

import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin';

admin.initializeApp(functions.config().firebase);
admin.firestore().settings({ timestampsInSnapshots: true });
const env = functions.config();
...

Run $ firebase deploy --only functions

Result

✔  functions: Finished running predeploy script.
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: mod.hasOwnProperty is not a function

Were you able to successfully deploy your functions?

No. I got the following error message - Error: mod.hasOwnProperty is not a function

Expected behavior

Functions should get deployed.

Actual behavior

Error: mod.hasOwnProperty is not a function

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joehancommented, Jan 9, 2019

@mlejva I took a look at the error message that you are getting, and I believe it is coming from extractTriggers.js (https://github.com/firebase/firebase-tools/blob/master/src/extractTriggers.js) in firebase-tools. This code is run when you ‘firebase deploy’ in order to find the names of your functions from what you export in index.ts. firebase deploy expects that src/index.ts is only exporting functions created via firebase-functions (or custom functions written to the same spec). You shouldn’t export other things in your index.ts file. Hopefully this helps! I’m going to close this since its not an issue with our codebase, but I’m happy to clarify any other questions you may have.

0reactions
matheocommented, Oct 6, 2019

I just found that some bundlers/optimizers can remove the __proto__ functions of the Object and that will break firebase-tools logic. See firebase/firebase-tools#1687

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase function deploy error in a typescript project with ...
Hi there I have an issue deploying my typescript express app to firebase via firebase-tools when that project contains another typescript ...
Read more >
Use TypeScript for Cloud Functions - Firebase
Following instructions in this guide, you can migrate an existing JavaScript project to TypeScript and continue deploying functions using a predeploy hook ...
Read more >
Troubleshooting Cloud Functions - Google Cloud
Function deployment fails due to Cloud Build not supporting VPC-SC. Cloud Functions uses Cloud Build to build your source code into a runnable...
Read more >
Error when deploying a Firebase cloud function - Google Groups
I also think that the words "failed create image cache" mean that it's related ... I'm writing my cloud functions in Typescript and...
Read more >
Cloud Build error when trying to update ... - Issue Tracker
Every single one is failing. I'm using Typescript to write my functions, with CLI deployment using the command 'firebase deploy'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found