New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESM modules not supported per Nodejs v14 docs #850
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
See:
Right now we don't support ES Modules but we're tracking it as a feature request. |
What is the fix for this error? We are on node v12.20.2, firebase-admin 9.2.0, firebase-functions 3.11.0 and our firebase deploy errors when we try to import a library built with |
Hey @jbistis. I don't have a full picture of what's going on with your setting based on the info you shared, but I do notice that you are using node.js 12. IIUC, node.js 12 does not supporrt ES modules - you need at least v13 for that. |
When I run firebase deploy --only functions, it fails with: I only get this error when I import models from our new lib. If I import models from our old lib, the firebase deploy command completes just fine. That is why I think there must be some difference in the tsconfig settings in the old lib that I am not setting in the new lib but cannot seem to find it. I have enableIvy set to false in both. Any ideas? |
From the error message, my guess is that your new lib packaged as a ES module whereas the old module was a commonjs module? Do you think that's making a difference? Also, I'd double check that you are using latest version of the Firebase CLI - the esmodule support was added only in the last few months. |
Excellent feedback. Thank you. The new lib is built with Angular CLI 13.4.1 and the old lib is Angular CLI 12.2.13. Both are firebase --version 9.2.1. I just tried publishing the a13 lib as a commonjs module using |
I think updating the firebase cli might help here, e.g.
I don't know the exact version of the CLI where we introduced the ES module support for functions, but 9.2.1 is definitely too old. |
I tried upgrading to both firebase-tools 9.23.3 and the latest version 10.0.1 which came out 19 days ago and the same error. ✔ functions: Finished running predeploy script. Error: Error occurred while parsing your function triggers. Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: functions/node_modules/@prometheuspartners/types/fesm2015/prometheuspartners-types.mjs |
@taeold, I redid the firebase-tools upgrade to 10.0.1 and it all working now. Fighting a different issue now. |
Related issues
I don't know.
[REQUIRED] Version info
firebase-functions:
firebase-tools:
firebase-admin:
[REQUIRED] Test case
No.
[REQUIRED] Steps to reproduce
[REQUIRED] Expected behavior
stdout shows
object
[REQUIRED] Actual behavior
Were you able to successfully deploy your functions?
Didn't try.
Same behavior in Nodejs v14 and v15 (this report from supported v14) and using
.mjs
extension instead of.js
also with adjustment to main to match.see also https://nodejs.org/docs/latest-v14.x/api/esm.html
The text was updated successfully, but these errors were encountered: