conventional-changelog: Error in version 7.0.1: `createPreset` is not a function.

Version 7.0.1 of this plugin has a bug that prevents release-it from running at all. When running release-it (presumably in the after:bump hook where this plugin should be running) an error will be thrown, saying that createPreset is not a function. This error exists on my local machine as well as Girhub Actions. I know the issue is this plugin because release-it was working correctly until this plugin was installed. For reference, I have included the package.json, .release-it.json, and release workflow yaml from one of my projects, as well as the output from release-it

package.json

{
  "name": "@garavest/prettier-config",
  "version": "1.0.0",
  "description": "This package contains Garavest LLC's prettier config, used for internal and shared projects.",
  "keywords": [
    "prettier",
    "config",
    "svelte",
    "tailwindcss"
  ],
  "repository": {
    "type": "git",
    "url": "git+https://github.com/garavest/prettier-config.git"
  },
  "license": "MIT",
  "author": {
    "name": "Seth Murphy",
    "email": "seth.murphy@garavest.com",
    "url": "https://garavest.com"
  },
  "type": "module",
  "main": "index.js",
  "scripts": {
    "lint": "npm run lint:code && npm run lint:format",
    "lint:code": "eslint .",
    "lint:format": "prettier -c .",
    "release": "release-it"
  },
  "dependencies": {
    "prettier": "^3.0.1",
    "prettier-plugin-svelte": "^3.0.3",
    "prettier-plugin-tailwindcss": "^0.5.3"
  },
  "devDependencies": {
    "@commitlint/cli": "^17.6.7",
    "@commitlint/config-conventional": "^17.6.7",
    "@garavest/eslint-config": "^1.0.2",
    "@release-it/conventional-changelog": "^7.0.1",
    "eslint": "^8.48.0",
    "husky": "^8.0.3",
    "lint-staged": "^14.0.1",
    "markdownlint": "^0.30.0",
    "markdownlint-cli": "^0.36.0",
    "release-it": "^16.1.5"
  }
}

.release-it.json

{
  "git": {
    "commitMessage": "chore: release v${version}",
    "requireBranch": "main"
  },
  "github": {
    "release": true
  },
  "hooks": {
    "before:init": ["git pull", "npm run lint"]
  },
  "npm": {
    "publish": true,
    "versionArgs": ["--allow-same-version"]
  },
  "plugins": {
    "@release-it/conventional-changelog": {
      "preset": "angular",
      "infile": "CHANGELOG.md"
    }
  },
  "publishConfig": {
    "access": "public"
  }
}

.github/workflows/release.yml

name: Release & Publish to NPM
on: workflow_dispatch
permissions:
  contents: write
jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Setup Node 18
        uses: actions/setup-node@v3
        with:
          node-version: "18.x"
          registry-url: "https://registry.npmjs.org"
      - name: Initialize git user
        run: |
          git config --global user.email "seth.murphy@garavest.com"
          git config --global user.name "Release Workflow"
      - name: Initialize NPM config
        run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      - name: Install the dependencies
        run: npm ci
      - name: Do the release
        run: npm run release --ci
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

release-it output

This is from Github Actions, but I get an idential error on my local machine.

Run npm run release --ci
  npm run release --ci
  shell: /usr/bin/bash -e {0}
  env:
    NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc
    NODE_AUTH_TOKEN: XXXXX-XXXXX-XXXXX-XXXXX
    GITHUB_TOKEN: ***
    NPM_TOKEN: ***
  
> @garavest/prettier-config@1.0.0 release
> release-it
- git pull
✔ git pull
- npm run lint
✔ npm run lint
ERROR createPreset is not a function
Error: Process completed with exit code 1.

For the time being, I will try reverting to version 7.0.0 and just ignore the PRs from Dependabot. I mainly just wanted to bring this to your attention.

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

From a small test, I also see now that in our code in the .yaml file, this code works:

plugins:
  '@release-it/conventional-changelog':
    preset:
      name: conventionalcommits

But this code fails:

plugins:
  '@release-it/conventional-changelog':
    preset:
      name: angular

returning the error ERROR The "angular" preset does not export a function. Maybe you are using an old version of the preset. Please upgrade.

So is the angular preset not usable anymore? I can also confirm the ERROR The "angular" preset does not export a function error and that swapping from angular to conventionalcommits does make it go away.

EDIT: I guess we’re waiting on this https://github.com/conventional-changelog/commitlint/issues/3698