pmowrer / semantic-release-monorepo

Apply semantic-release's automatic publishing to a monorepo.
MIT License
510 stars 79 forks source link

ERR_REQUIRED_ESM error with semantic-release/gitlab #136

Closed karlomedallo closed 8 months ago

karlomedallo commented 1 year ago

Hi, I'm not sure if this error is from semantic-release-monorepo or from @semantic-release/gitlab

I have posted it here:

https://github.com/semantic-release/gitlab/issues/493

and here's the error:

[12:10:32 PM] [semantic-release] › ✘  An error occurred while running semantic-release: Error [ERR_REQUIRE_ESM]: require() of ES Module /builds/repo/node_modules/.pnpm/@semantic-release+gitlab@10.1.4_semantic-release@20.1.0/node_modules/@semantic-release/gitlab/index.js from /builds/repo/node_modules/.pnpm/semantic-release-plugin-decorators@3.0.1_semantic-release@20.1.0/node_modules/semantic-release-plugin-decorators/src/wrapStep.js not supported.
Instead change the require of index.js in /builds/repo/node_modules/.pnpm/semantic-release-plugin-decorators@3.0.1_semantic-release@20.1.0/node_modules/semantic-release-plugin-decorators/src/wrapStep.js to a dynamic import() which is available in all CommonJS modules.
    at semantic-release-monorepo (/builds/repo/node_modules/.pnpm/semantic-release-plugin-decorators@3.0.1_semantic-release@20.1.0/node_modules/semantic-release-plugin-decorators/src/wrapStep.js:49:24)
    at validator (file:///builds/repo/node_modules/.pnpm/semantic-release@20.1.0/node_modules/semantic-release/lib/plugins/normalize.js:36:30)
    at file:///builds/repo/node_modules/.pnpm/semantic-release@20.1.0/node_modules/semantic-release/lib/plugins/pipeline.js:37:40
    at next (file:///builds/repo/node_modules/.pnpm/p-reduce@3.0.0/node_modules/p-reduce/index.js:16:10) {
  code: 'ERR_REQUIRE_ESM',
  pluginName: '[Function: semantic-release-monorepo]'
}
Error [ERR_REQUIRE_ESM]: require() of ES Module /builds/repo/node_modules/.pnpm/@semantic-release+gitlab@10.1.4_semantic-release@20.1.0/node_modules/@semantic-release/gitlab/index.js from /builds/repo/node_modules/.pnpm/semantic-release-plugin-decorators@3.0.1_semantic-release@20.1.0/node_modules/semantic-release-plugin-decorators/src/wrapStep.js not supported.
Instead change the require of index.js in /builds/repo/node_modules/.pnpm/semantic-release-plugin-decorators@3.0.1_semantic-release@20.1.0/node_modules/semantic-release-plugin-decorators/src/wrapStep.js to a dynamic import() which is available in all CommonJS modules.
    at semantic-release-monorepo (/builds/repo/node_modules/.pnpm/semantic-release-plugin-decorators@3.0.1_semantic-release@20.1.0/node_modules/semantic-release-plugin-decorators/src/wrapStep.js:49:24)
    at validator (file:///builds/repo/node_modules/.pnpm/semantic-release@20.1.0/node_modules/semantic-release/lib/plugins/normalize.js:36:30)
    at file:///builds/repo/node_modules/.pnpm/semantic-release@20.1.0/node_modules/semantic-release/lib/plugins/pipeline.js:37:40
    at next (file:///builds/repo/node_modules/.pnpm/p-reduce@3.0.0/node_modules/p-reduce/index.js:16:10) {
  code: 'ERR_REQUIRE_ESM',
  pluginName: '[Function: semantic-release-monorepo]'
}undefined
/builds/repo/src/libs/eslint-config:
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with exit code 1: node_modules/.bin/semantic-release
 ELIFECYCLE  Command failed with exit code 1.
JonasSchubert commented 1 year ago

@semantic-release/gitlab was recently changed to ESM only. As #135 describes this is most likely the cause for your error. This package has to be migrated to ESM too, if you want to use v10 of @semantic-release/gitlab. Maybe try v9 and check whether it works with the previous version.

villelahdenvuo commented 1 year ago

Same is happening with other parts of semantic-release, I guess this plugin needs to be updated to ESM to continue working...

[11:24:22 AM] [semantic-release] › ✘  Failed step "analyzeCommits" of plugin "[Function: semantic-release-monorepo]"
[11:24:22 AM] [semantic-release] › ✘  An error occurred while running semantic-release: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/circleci/repo/node_modules/@semantic-release/npm/index.js from /home/circleci/repo/node_modules/semantic-release-plugin-decorators/src/wrapStep.js not supported.
Instead change the require of index.js in /home/circleci/repo/node_modules/semantic-release-plugin-decorators/src/wrapStep.js to a dynamic import() which is available in all CommonJS modules.
    at semantic-release-monorepo (/home/circleci/repo/node_modules/semantic-release-plugin-decorators/src/wrapStep.js:49:24)
    at validator (file:///home/circleci/repo/node_modules/semantic-release/lib/plugins/normalize.js:36:30)
    at file:///home/circleci/repo/node_modules/semantic-release/lib/plugins/pipeline.js:38:42
    at next (file:///home/circleci/repo/node_modules/p-reduce/index.js:16:10) {
  code: 'ERR_REQUIRE_ESM',
  pluginName: '[Function: semantic-release-monorepo]'
}

Edit: Looks like there's a PR https://github.com/pmowrer/semantic-release-monorepo/pull/137

JOU-amjs commented 1 year ago

same problems.

[10:45:04 AM] [semantic-release] › ✘  An error occurred while running semantic-release: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/scene/scene/node_modules/@semantic-release/commit-analyzer/index.js from /home/runner/work/scene/scene/node_modules/semantic-release-plugin-decorators/src/wrapStep.js not supported.
Instead change the require of index.js in /home/runner/work/scene/scene/node_modules/semantic-release-plugin-decorators/src/wrapStep.js to a dynamic import() which is available in all CommonJS modules.
    at semantic-release-monorepo (/home/runner/work/scene/scene/node_modules/semantic-release-plugin-decorators/src/wrapStep.js:49:24)
    at validator (file:///home/runner/work/scene/scene/node_modules/semantic-release/lib/plugins/normalize.js:36:30)
    at file:///home/runner/work/scene/scene/node_modules/semantic-release/lib/plugins/pipeline.js:[38](https://github.com/alovajs/scene/actions/runs/5411307043/jobs/9833872625#step:5:39):[42](https://github.com/alovajs/scene/actions/runs/5411307043/jobs/9833872625#step:5:43)
    at next (file:///home/runner/work/scene/scene/node_modules/semantic-release/node_modules/p-reduce/index.js:16:10) {
  code: 'ERR_REQUIRE_ESM',
  pluginName: '[Function: semantic-release-monorepo]'
}
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/runner/work/scene/scene/node_modules/@semantic-release/commit-analyzer/index.js from /home/runner/work/scene/scene/node_modules/semantic-release-plugin-decorators/src/wrapStep.js not supported.
Instead change the require of index.js in /home/runner/work/scene/scene/node_modules/semantic-release-plugin-decorators/src/wrapStep.js to a dynamic import() which is available in all CommonJS modules.
    at semantic-release-monorepo (/home/runner/work/scene/scene/node_modules/semantic-release-plugin-decorators/src/wrapStep.js:[49](https://github.com/alovajs/scene/actions/runs/5411307043/jobs/9833872625#step:5:50):24)
    at validator (file:///home/runner/work/scene/scene/node_modules/semantic-release/lib/plugins/normalize.js:36:30)
    at file:///home/runner/work/scene/scene/node_modules/semantic-release/lib/plugins/pipeline.js:38:42
    at next (file:///home/runner/work/scene/scene/node_modules/semantic-release/node_modules/p-reduce/index.js:16:10) {
  code: 'ERR_REQUIRE_ESM',
  pluginName: '[Function: semantic-release-monorepo]'
}npm ERR! Lifecycle script `release` failed with error: 
npm ERR! Error: command failed 
npm ERR!   in workspace: @alova/scene-vue@1.1.0 
npm ERR!   at location: /home/runner/work/scene/scene/packages/scene-vue 
Error: Process completed with exit code 1.
jcapogna commented 1 year ago

Related issue in the @semantic-release/gitlab project: https://github.com/semantic-release/gitlab/issues/493

The solution appears to be downgrade to @semantic-release/gitlab v9 until semantic-release-monorepo is updated to support ESM. This worked for me.

jcapogna commented 1 year ago

@semantic-release/commit-analyzer and @semantic-release/npm also recently moved to ESM. You need to downgrade those to v9 too.

I created #138 to document which plugins need to be downgraded due to lack of ESM support in semantic-release-monorepo.

bryanjtc commented 11 months ago

I published a new package semantic-release-monorepo-esm that supports esm. v1.0.10 should work without issues. The new package is based on the changes in this pr. https://github.com/pmowrer/semantic-release-monorepo/pull/143

karlo-humanmanaged commented 10 months ago

@bryanjtc : Just wondering why don't you just start a new repo completely based on what you have done? I think it is awesome that you get to work on this. I really find that this repo is not really maintained. I'm actually looking at other solutions and migrating our codebase away from this

bryanjtc commented 10 months ago

@bryanjtc : Just wondering why don't you just start a new repo completely based on what you have done? I think it is awesome that you get to work on this. I really find that this repo is not really maintained. I'm actually looking at other solutions and migrating our codebase away from this

I have been thinking to do that for a while now. The plan is to keep updating semantic-release-esm to just support new semantic-release versions. Easier to maintain that way. I also want to create new packages one as a config and another as a plugin for monorepos using semantic-release. These new packages can have new, maybe breaking features, such as support for dotnet and other feature requests from this repo.

mario-jerkovic commented 9 months ago

@karlo-humanmanaged @jcapogna
We've released a monorepo package that's compatible with ESM, and since you have access to the source code, you're free to customize it as you wish. Cheers! 🍻

NPM package: https://www.npmjs.com/package/@rimac-technology/semantic-release-monorepo Source code: https://github.com/RimacTechnology/semantic-release-monorepo

github-actions[bot] commented 8 months ago

:tada: This issue has been resolved in version 8.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

kpturner commented 7 months ago

🎉 This issue has been resolved in version 8.0.0 🎉

Which issue?