semantic-release / semantic-release/release-notes-generator

`MODULE_NOT_FOUND` when running with `npx`

Open
#565 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
368
Forks
55
Avg merge
10m
Merged PRs (30d)
1

Description

I have a github action which executes semantic-release with npx. The project does not have a package.json.

Everything seems to work fine, before failing with error Cannot find module 'conventional-changelog-conventionalcommits'

.releaserc.yml
branches:
  - main
  - name: beta
    prerelease: beta
debug: true
plugins:
  - "@semantic-release/commit-analyzer"
  - path: "@semantic-release/release-notes-generator"
    preset: conventionalcommits
  - "@semantic-release/github"
workflow.yml
on:
  workflow_dispatch:

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest

    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      NODE_VERSION: "20.x"

    steps:
      - uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: Run `semantic-release`
        run: |
          npx --yes semantic-release --dry-run
logs
Run npx --yes semantic-release  --dry-run
  npx --yes semantic-release  --dry-run
  shell: /usr/bin/bash -e {0}
  env:
    NODE_VERSION: 20.x
    GH_TOKEN: ***
npm WARN deprecated read-pkg-up@11.0.0: Renamed to read-package-up
[12:48:09 AM] [semantic-release] › ℹ  Running semantic-release version 22.0.8
[12:48:09 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
[12:48:09 AM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[12:48:09 AM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[12:48:09 AM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[12:48:09 AM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[12:48:09 AM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[12:48:09 AM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[...]
[12:48:12 AM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[12:48:12 AM] [semantic-release] › ℹ  There is no previous release, the next release version is 1.0.0-stage.1
[12:48:12 AM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[12:48:12 AM] [semantic-release] › ✘  Failed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[12:48:12 AM] [semantic-release] › ✘  An error occurred while running semantic-release: Error: Cannot find module 'conventional-changelog-conventionalcommits'
    at importFrom (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/import-from-esm/index.js:100:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async default (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/@semantic-release/release-notes-generator/lib/load-changelog-config.js:27:63)
    at async generateNotes (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/@semantic-release/release-notes-generator/index.js:34:38)
    at async validator (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
    at async file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
    at async file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/pipeline.js:32:5
    at async pluginsConfigAccumulator.<computed> [as generateNotes] (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/index.js:87:11)
    at async run (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/index.js:197:23)
    at async Module.default (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/index.js:275:22) {
  code: 'MODULE_NOT_FOUND',
  pluginName: '@semantic-release/release-notes-generator'
}
Error: Cannot find module 'conventional-changelog-conventionalcommits'
    at importFrom (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/import-from-esm/index.js:100:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async default (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/@semantic-release/release-notes-generator/lib/load-changelog-config.js:27:63)
    at async generateNotes (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/@semantic-release/release-notes-generator/index.js:34:38)
    at async validator (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/normalize.js:36:24)
    at async file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/pipeline.js:38:36
    at async file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/pipeline.js:32:5
    at async pluginsConfigAccumulator.<computed> [as generateNotes] (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/lib/plugins/index.js:87:11)
    at async run (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/index.js:197:23)
    at async Module.default (file:///home/runner/.npm/_npx/cdf31b77322f1d44/node_modules/semantic-release/index.js:275:22) {
  code: 'MODULE_NOT_FOUND',
  pluginName: '@semantic-release/release-notes-generator'
}
Error: Process completed with exit code 1.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/load-changelog-config.js, reached from generateNotes in index.js, and reproduce the reported npx --yes semantic-release --dry-run workflow without a package.json. Done means the conventionalcommits preset no longer raises MODULE_NOT_FOUND for conventional-changelog-conventionalcommits.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
release, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.