Skip to content

commitizen init doesn't work with pnpm #858

Closed
@sunnz

Description

@sunnz

I had run the commitizen init cz-conventional-changelog --save-dev --save-exact command as per README, but it doesn't work, see a copy and paste of the error from commitizen at the end.

Suggestion: when there exists a pnpm-lock.yaml file, use pnpm instead of npm.

Here's my workaround:

pnpm add -D -E cz-conventional-changelog

Then add this block to the package.json file:

  "config": {
    "commitizen": {
      "path": "cz-conventional-changelog"
    }
  },

The cz command works as usual from this point.

Error from commitizen init cz-conventional-changelog --save-dev --save-exact:

Attempting to initialize using the npm package cz-conventional-changelog
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name ".pnpm": name cannot start with a period

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sunnz/.npm/_logs/2021-11-10T12_28_43_823Z-debug.log
Error: Command failed: npm install cz-conventional-changelog --save-dev
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm ERR! code EINVALIDPACKAGENAME
npm ERR! Invalid package name ".pnpm": name cannot start with a period

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sunnz/.npm/_logs/2021-11-10T12_28_43_823Z-debug.log

    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15)
    at init (/Users/sunnz/Library/pnpm/nodejs/16.11.1/pnpm-global/5/node_modules/.pnpm/commitizen@4.2.4/node_modules/commitizen/dist/commitizen/init.js:1017:28)
    at Object.bootstrap (/Users/sunnz/Library/pnpm/nodejs/16.11.1/pnpm-global/5/node_modules/.pnpm/commitizen@4.2.4/node_modules/commitizen/dist/cli/commitizen.js:34:30)
    at Object.<anonymous> (/Users/sunnz/Library/pnpm/nodejs/16.11.1/pnpm-global/5/node_modules/.pnpm/commitizen@4.2.4/node_modules/commitizen/bin/commitizen.js:2:38)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer >,
    <Buffer 6e 70 6d 20 57 41 52 4e 20 6f 6c 64 20 6c 6f 63 6b 66 69 6c 65 20 0a 6e 70 6d 20 57 41 52 4e 20 6f 6c 64 20 6c 6f 63 6b 66 69 6c 65 20 54 68 65 20 70 ... 491 more bytes>
  ],
  pid: 55718,
  stdout: <Buffer >,
  stderr: <Buffer 6e 70 6d 20 57 41 52 4e 20 6f 6c 64 20 6c 6f 63 6b 66 69 6c 65 20 0a 6e 70 6d 20 57 41 52 4e 20 6f 6c 64 20 6c 6f 63 6b 66 69 6c 65 20 54 68 65 20 70 ... 491 more bytes>
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions