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

An error occurred while running semantic-release: SyntaxError: Unexpected identifier 'assert' #3280

Closed
dhoppe opened this issue Apr 29, 2024 · 6 comments

Comments

@dhoppe
Copy link

dhoppe commented Apr 29, 2024

Current behavior

The GitLab CI pipeline has been failing for a few days, although there have been no changes to the code. Therefore, I suspect that this problem is caused by one of the dependencies.

Expected behavior

A new release is created.

semantic-release version

23.0.8

CI environment

GitLab

Plugins used

@semantic-release/commit-analyzer
@semantic-release/release-notes-generator
@semantic-release/gitlab
@semantic-release/changelog
@semantic-release/git

semantic-release configuration

{
  "branches": ["main"],
  "ci": false,
  "plugins": [
    [
      "@semantic-release/commit-analyzer",
      {
        "preset": "conventionalcommits"
      }
    ],
    [
      "@semantic-release/release-notes-generator",
      {
        "preset": "conventionalcommits"
      }
    ],
    [
      "@semantic-release/gitlab",
       {
         "successComment": "This issue has been resolved in version ${nextRelease.version} :tada:",
         "labels": false
       }
    ],
    [
      "@semantic-release/changelog",
      {
        "changelogFile": "CHANGELOG.md",
        "changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
      }
    ],
    [
      "@semantic-release/git",
      {
        "assets": ["CHANGELOG.md"],
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ]
  ]
}

CI logs

$ npx semantic-release --debug
[9:58:28 AM] [semantic-release] › ℹ  Running semantic-release version 23.0.8
2024-04-29T09:58:28.546Z semantic-release:config load config from: /builds/ci-templates-48151/renovate-ci-runner/.releaserc.json
2024-04-29T09:58:28.556Z semantic-release:config options values: {
  branches: [ 'main' ],
  repositoryUrl: 'https://gitlab-ci-token:[secure]@gitlab.com/ci-templates-48151/renovate-ci-runner.git',
  tagFormat: 'v${version}',
  plugins: [
    [ '@semantic-release/commit-analyzer', [Object] ],
    [ '@semantic-release/release-notes-generator', [Object] ],
    [ '@semantic-release/gitlab', [Object] ],
    [ '@semantic-release/changelog', [Object] ],
    [ '@semantic-release/git', [Object] ]
  ],
  ci: false,
  _: [],
  debug: true,
  '$0': 'node_modules/.bin/semantic-release',
  noCi: true
}
[9:58:28 AM] [semantic-release] › ✘  An error occurred while running semantic-release: SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:1[66](https://gitlab.com/ci-templates-48151/renovate-ci-runner/-/jobs/6737347977#L66):18)
    at callTranslator (node:internal/modules/esm/loader:416:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)
SyntaxError: Unexpected identifier 'assert'
    at compileSourceTextModule (node:internal/modules/esm/utils:337:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:166:18)
    at callTranslator (node:internal/modules/esm/loader:416:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:422:30)
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
@tuytoosh
Copy link

I have the same issue with my pipelines :( Apparently, there has been a backward incompatible change in the last few days...

@travi
Copy link
Member

travi commented Apr 29, 2024

See semantic-release/gitlab#705

@travi
Copy link
Member

travi commented Apr 29, 2024

Apparently, there has been a backward incompatible change in the last few days...

Node v22 became "current" a few days ago. There was no backwards incompatible change made on the semantic-release side. You likely do not have your node version pinned within your pipeline, so your underlying version likely updated with that status change. Worth noting that v22 is not yet considered lts for another six months.

@tuytoosh
Copy link

@travi Thank you for your comments. As you said, for now, I fixed it with setting the node on a specific version.

For those who are looking for a quick fix:

version:
  stage: version
  image: node:20.10.0-alpine
  ...

@dhoppe
Copy link
Author

dhoppe commented Apr 29, 2024

@travi Thank you for pointing me into the right direction.

I just checked the Docker containers and in my case the versions have not changed.

Alpine: 3.19
Node.js: v21.7.3
NPM: 10.5.0

However, the following downgrade has fixed the GitLab CI pipeline.

diff --git a/release/semantic.yml b/release/semantic.yml
index e1fd3c1..13afc93 100644
--- a/release/semantic.yml
+++ b/release/semantic.yml
@@ -2,7 +2,7 @@
 spec:
   inputs:
     image:
-      default: registry.hub.docker.com/library/node:alpine
+      default: registry.hub.docker.com/library/node:lts-alpine

 ---
 .release:semantic:

@travi
Copy link
Member

travi commented Apr 29, 2024

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

3 participants