-
Notifications
You must be signed in to change notification settings - Fork 54
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
ERR_REQUIRE_ESM in Node 16.6 #116
Comments
I have workarounded this problem by using diff --git a/dist/contentful-typescript-codegen.js b/dist/contentful-typescript-codegen.js
index aeb08f170f0783aa9f44abc0a53999e808d5727d..0d1e439fbc070669405d1d18aac3c017bc8c69bc 100755
--- a/dist/contentful-typescript-codegen.js
+++ b/dist/contentful-typescript-codegen.js
@@ -443,6 +443,8 @@ function determineEnvironmentPath() {
var pathWithoutExtension = path.resolve(process.cwd(), "./getContentfulEnvironment");
if (fs.existsSync(pathWithoutExtension + ".ts")) {
return pathWithoutExtension + ".ts";
+ } else if (fs.existsSync(pathWithoutExtension + ".cjs")){
+ return pathWithoutExtension + ".cjs";
}
return pathWithoutExtension + ".js";
} |
@pmb0 it seems like that doesn't work for me, did you change anything else? |
What worked for me was:
Hope this helps! |
I opened a PR to apply the above patch on the package, in case you want to follow it: #159 |
I have a same issue. When will be deploy a new version? |
I've got "ERR_REQUIRE_ESM" in Node v16.6.
One cannot
require
an EJS module, which Node v16 determines it by the extension being.js
.This filename with
.js
is hard-coded innode_modules/contentful-typescript-codegen/dist/contentful-typescript-codegen.js
. I can monkey-patch this, but it would also be helpful if we can specify the path for this in command line.The text was updated successfully, but these errors were encountered: