semantic-release: @semantic-release/npm silently failing in Github actions therefore not publishing package
Current behavior
When running through the Github actions every action passes and the tags and release are made but the package.json version isn’t updated and the package isn’t published.
I’ve got the same setup in another project and everything is working as expected
Expected behavior
I’m expecting to have all the tags and releases working (which they are) and the version number in the package.json updated to latest tag and to be published
Environment
- semantic-release version: 18.0.0
- CI environment: Github actions
- Plugins used: – “@semantic-release/commit-analyzer”, – “@semantic-release/release-notes-generator”, – “@semantic-release/changelog”, – “@semantic-release/npm”, – “@semantic-release/github”
- semantic-release configuration:
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
"next",
"next-major",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github"
]
}
- CI logs:
[5:36:10 PM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/npm"
[5:36:10 PM] [semantic-release] [@semantic-release/npm] › ℹ Write version 1.1.0-alpha.4 to package.json in /home/runner/work/my-package/my-package
(node:2296) UnhandledPromiseRejectionWarning: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/runner/work/my-package/my-package/node_modules/npm/node_modules/chalk/source/index.js
require() of ES modules is not supported.
require() of /home/runner/work/my-package/my-package/node_modules/npm/node_modules/chalk/source/index.js from /home/runner/work/my-package/my-package/node_modules/npm/lib/utils/explain-dep.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/runner/work/my-package/my-package/node_modules/npm/node_modules/chalk/package.json.
at new NodeError (internal/errors.js:322:7)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/home/runner/work/my-package/my-package/node_modules/npm/lib/utils/explain-dep.js:1:15)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2296) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2296) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[5:36:10 PM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/npm"
[5:36:12 PM] [semantic-release] › ✔ Created tag v1.1.0-alpha.4
[5:36:12 PM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/npm"
[5:36:12 PM] [semantic-release] [@semantic-release/npm] › ℹ Publishing version 1.1.0-alpha.4 to npm registry on dist-tag alpha
(node:2322) UnhandledPromiseRejectionWarning: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/runner/work/my-package/my-package/node_modules/npm/node_modules/chalk/source/index.js
require() of ES modules is not supported.
require() of /home/runner/work/my-package/my-package/node_modules/npm/node_modules/chalk/source/index.js from /home/runner/work/my-package/my-package/node_modules/npm/lib/utils/explain-dep.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/runner/work/my-package/my-package/node_modules/npm/node_modules/chalk/package.json.
at new NodeError (internal/errors.js:322:7)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/home/runner/work/my-package/my-package/node_modules/npm/lib/utils/explain-dep.js:1:15)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2322) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[5:36:12 PM] [semantic-release] [@semantic-release/npm] › ℹ Published @MyOrg/my-package@1.1.0-alpha.4 to dist-tag @alpha on https://npm.pkg.github.com
[5:36:12 PM] [semantic-release] › ✔ Completed step "publish" of plugin "@semantic-release/npm"
[5:36:12 PM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/github"
[5:36:12 PM] [semantic-release] [@semantic-release/github] › ℹ Published GitHub release: https://github.com/MyOrg/my-package/releases/tag/v1.1.0-alpha.4
[5:36:12 PM] [semantic-release] › ✔ Completed step "publish" of plugin "@semantic-release/github"
[5:36:12 PM] [semantic-release] › ℹ Start step "success" of plugin "@semantic-release/github"
[5:36:16 PM] [semantic-release] [@semantic-release/github] › ℹ Added comment to issue #5: https://github.com/MyOrg/my-package/pull/5#issuecomment-1010200825
[5:36:18 PM] [semantic-release] [@semantic-release/github] › ℹ Added labels [ 'released on @alpha' ] to issue #5
[5:36:19 PM] [semantic-release] › ✔ Completed step "success" of plugin "@semantic-release/githu
[5:36:19 PM] [semantic-release] › ✔ Published release 1.1.0-alpha.4 on alpha channel
This is a screen shot of the releases but no the packages been published b"
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 7
- Comments: 19 (6 by maintainers)
Commits related to this issue
- fix: revert "chore(deps): update dependency semantic-release to v19" Updating semantic-release to v19 has caused some weird behaviour in `yarn.lock` with chalk version range being `*` instead of the ... — committed to gravitee-io/gravitee-ui-components by gaetanmaisse 2 years ago
- fix: revert "chore(deps): update dependency semantic-release to v19" Updating semantic-release to v19 has caused some weird behaviour in `yarn.lock` with chalk version range being `*` instead of the ... — committed to gravitee-io/gravitee-ui-components by gaetanmaisse 2 years ago
- fix: pin semantic-release to v18.0.1 https://github.com/semantic-release/semantic-release/issues/2323 — committed to redabacha/magnolia-react-editor by redabacha 2 years ago
- fix: pin semantic-release to v18.0.1 https://github.com/semantic-release/semantic-release/issues/2323 — committed to redabacha/magnolia-react-editor by redabacha 2 years ago
- Revert "chore(deps): update dependency semantic-release to v19 (#731)" Latest `semantic-release` fails on CI: ``` /home/runner/work/react-native-test-app/react-native-test-app/node_modules/npm/lib/u... — committed to microsoft/react-native-test-app by tido64 2 years ago
- Revert "chore(deps): update dependency semantic-release to v19 (#731)" (#734) Latest `semantic-release` fails on CI: ``` /home/runner/work/react-native-test-app/react-native-test-app/node_modules... — committed to microsoft/react-native-test-app by tido64 2 years ago
- chore(semantic-release): pin semantic-release semantic-release/semantic-release#2323 — committed to cassels/dotpref by cassels 2 years ago
- chore(semantic-release): pin semantic-release (#277) semantic-release/semantic-release#2323 — committed to cassels/dotpref by cassels 2 years ago
- fix: deal with https://github.com/semantic-release/semantic-release/issues/2323 — committed to WillBooster/wbfy by exKAZUu 2 years ago
- chore: npm should use chalk v4 https://github.com/semantic-release/semantic-release/issues/2323 — committed to enisdenjo/graphql-ws by enisdenjo 2 years ago
- chore: dont use chalk v5 See https://github.com/semantic-release/semantic-release/issues/2323 — committed to P4sca1/cron-schedule by P4sca1 2 years ago
- build(deps-dev): set chalk version to ^4.1.2 https://github.com/semantic-release/semantic-release/issues/2323 — committed to culur/stylelint-config by phamhongphuc 2 years ago
- build(deps-dev): set chalk version to ^4.1.2 https://github.com/semantic-release/semantic-release/issues/2323 — committed to culur/prettier-config by phamhongphuc 2 years ago
- build(deps-dev): set chalk version to ^4.1.2 https://github.com/semantic-release/semantic-release/issues/2323 — committed to culur/prettier-config by phamhongphuc 2 years ago
- build(deps-dev): set chalk version to ^4.1.2 https://github.com/semantic-release/semantic-release/issues/2323 — committed to culur/prettier-config by phamhongphuc 2 years ago
- fix: npm's stupid mistake https://github.com/semantic-release/semantic-release/issues/2323 — committed to SeedCompany/eslint-plugin by CarsonF 2 years ago
- fix: npm's stupid mistake https://github.com/semantic-release/semantic-release/issues/2323 — committed to SeedCompany/eslint-plugin by CarsonF 2 years ago
- build(deps): npm needs chalk v4 semantic-release/semantic-release#2323 — committed to polonel/trudesk by polonel 2 years ago
- build(yarn): force chalk to v4 because of semantic-release/semantic-release#2323 — committed to ivangabriele/semantic-release-config by ivangabriele a year ago
If using Yarn, a workaround is adding
to your package.json
note that this fails now if you update
npm
past 9.7.0. Then your releases fail in the semantic-release/npm prepare step without any output. Took me hours to figure this out.Does
yarn@3
not respect bundled dependencies? 🤔npm
bundles all of our dependencies so references inpackage.json
should not be then used to fetch remote versions of those deps. This seems like a bug withyarn
(maybe it’s considered a feature? 🤷🏼♂️) if you happen to be using it to manage/installnpm
(something I would never recommend tbqh)As far as the “why does it say
"*"
when the package’spackage.json
has versions defined?”, the registry response shared is called a “Packument” (ie. Package + Document - old package metadata API ref) & it’s not a 1:1 representation ofpackage.json
.When you specify a dependency that is also specified in
bundledDependencies
, it’s going to map the version to"*"
(ie. signalling to take whatever is in this package). Notably, you don’t actually have to even specifydependencies
that you’re going to bundle (ref. https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bundleddependencies); this practice is just a matter of convenience for maintenance/development purposes.fascinating, let me reach out to the npm team
I have no idea why but by looking at my commit logs this happened when I had yarn version updated via
yarn set version stable
.@gr2m got the same error after updating @semantic-release/npm to v9 and semantic-release to v19.0.2 NodeJS version is v16.13.2