Skip to content
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

main / release fails with Error [ERR_REQUIRE_ESM] #711

Closed
MikeMcC399 opened this issue Jan 8, 2023 · 1 comment
Closed

main / release fails with Error [ERR_REQUIRE_ESM] #711

MikeMcC399 opened this issue Jan 8, 2023 · 1 comment

Comments

@MikeMcC399
Copy link
Collaborator

MikeMcC399 commented Jan 8, 2023

Action status

Problem description

The npm action @cycjimmy/semantic-release-action v2 now fails in GitHub when it is invoked from main.yml. This prevents any new release of GHA.

It produces the following error message:

Error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/semantic-release/index.js
require() of ES modules is not supported.
require() of /home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/semantic-release/index.js from /home/runner/work/_actions/cycjimmy/semantic-release-action/v2/src/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/semantic-release/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/runner/work/_actions/cycjimmy/semantic-release-action/v2/node_modules/semantic-release/package.json.

Steps to reproduce the issue

View job 6577990409.

Expected behavior

When the action main.yml runs, it should not fail.

Analysis

cycjimmy/semantic-release-action provides the optional parameter semantic_version to specify the version of the npm package semantic-release. This parameter is not specified in main.yml, and the latest available version of semantic-release v20 is therefore used.

semantic-release v20.0.0 was released on Jan 6, 2023 and according to the release notes it contains breaking changes related to ESM-only and minimum Node.js 18.

Suggested Fix

Update to cycjimmy/semantic-release-action v3.

Version v3 of the action cycjimmy/semantic-release-action specifies the compatible semantic-release v19.0.5 in its package.json so it avoids provoking the ESM error in this way without requiring the parameter semantic_version to be defined in main.yml.

@MikeMcC399
Copy link
Collaborator Author

Job 6609118202 was successful after a re-run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant