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.

Firebase Deploy Error: "Mux is not a constructor"

See original GitHub issue

I’m having an issue when trying to deploy code with the newest Mux version (3.0.2 – using typescript types). Note: previous Mux versions (before Typescript support worked fine)

I’m deploying my code to Firebase’s cloud functions via the firebase deploy --only functions command.

The code is able to build correctly without errors, but Firebase’s deploy command will throw the following:

Error: Error occurred while parsing your function triggers.

TypeError: Mux is not a constructor
    at Object.<anonymous> (/mnt/l/projects/my_fb_project/backend/functions/lib/index.js:44:57)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at /mnt/l/projects/my_fb_project/backend/functions/node_modules/firebase-tools/lib/triggerParser.js:15:15
    at Object.<anonymous> (/mnt/l/projects/my_fb_project/backend/functions/node_modules/firebase-tools/lib/triggerParser.js:53:3)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kevmo314commented, Sep 5, 2020

I temporarily worked around this by using

const Mux = require('@mux/mux-node');

instead of the standard ts import Mux from '@mux/mux-node'. Inspecting the typescript output, it produces:

var mux_node_1 = require('@mux/mux-node');

var Mux = mux_node_1.default(...);

and unsurprisingly, mux_node_1.default is undefined. Manually confirming this, require('@mux/mux-node').default is undefined.

I’m guessing this project has its exports misconfigured, specifically default exports should be module.exports.default = . I sent a pull request to add an ES6 default export.

1reaction
CubitSpeedcommented, Sep 22, 2020

Thank you everyone. Looks like it is working now

Read more comments on GitHub >

github_iconTop Results From Across the Web

Firebase is not a constructor error(using firebase with react)
When ever i am running code it gives me "Firebase is not a constructor". also tried with componentWillMount but nothing works. I try...
Read more >
Manage functions | Cloud Functions for Firebase - Google
To avoid errors, change a function's trigger type by this procedure: Modify the source code to include a new function with the desired...
Read more >
centiment package - github.com/elithrar/centiment - Go Packages
TODO(matt): Create a NewServer constructor -> call srv.Run() ... It will return a nil value and no error if no record was found....
Read more >
flutter/flutter_web - Gitter
https://medium.com/flutter-community/flutter-create-and-deploy-a-website-from ... -on-textfields-not-working-flutter-web When tabbing through a form on web, ...
Read more >
Stripe | (p)retired
An application user will interact with Firebase Authentication, logging in using ... minor errors and the Golang server code referenced an outdated module....
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