-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
Error [ERR_REQUIRE_ESM]
: Must use import to load ES Module: ROOT\node_modules\camelcase-keys\index.js
#93
Comments
@sindresorhus How would this work with Nest.js |
I ended up simply using: _.mapKeys(obj, (v, k) => _.camelCase(k)) Since importing the package was not easily possible with Nest.js unfortunately |
What is "_" and obj here? |
|
Hello all. I've created a util to convert ESM-only packages to CJS, for those who need it. This is still very much a work in progress, so please open an issue on the repository with any feedback. This package ( |
Because I wanted to use the latest version of this library I used an approach where I used ESBuild to convert this ESM only lib to CJS format. This should work for most of such cases and ideally you wont have to do this often as there aren't many libraries that have removed CJS support. In addition to that doing this for these type small util libraries, you likely don't really need to update ever them unless there is some serious security issue in which case you can use repeat the process again. So I ran ESBuild, took the built result and the
If you want you can probably alias it or something and make the import cleaner but this is fine for my needs, typing also works perfectly. Cheers. |
Getting error on
firebase deploy
. Full error belowError: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\node\codelabs\in_app_purchases\complete\firebase-backend\functions\node_modules\camelcase-keys\index.js require() of ES modules is not supported.
14.18.2
11.1.0
{ "compilerOptions": { "module": "commonjs", "noImplicitReturns": true, "noUnusedLocals": true, "outDir": "lib", "sourceMap": true, "strict": true, "target": "es2017", "resolveJsonModule": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true }, "compileOnSave": true, "include": [ "src" ] }
https://codelabs.developers.google.com/codelabs/flutter-in-app-purchases#10
https://github.com/flutter/codelabs/tree/master/in_app_purchases/complete/firebase-backend
The text was updated successfully, but these errors were encountered: