Skip to content

main / release fails with Error [ERR_REQUIRE_ESM] #711

@MikeMcC399

Description

@MikeMcC399

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions