commitizen / cz-cli

The commitizen command line utility. #BlackLivesMatter
http://commitizen.github.io/cz-cli/
MIT License
16.9k stars 552 forks source link

path resolve failed on MSYS2+zsh environment #823

Open boxsnake opened 3 years ago

boxsnake commented 3 years ago

OS Version: Windows 10 ver 1909 (18363.1500) node version: v14.10.0 npm version: v6.14.8

In my situation, I installed msys2 & zsh on Windows, and I use zsh as my shell. My Node.JS is Windows version.

When I use commitizen, it fails in resolve the path for cz-conventional-changelog.

In my package.json

{
  ...
  "scripts": {
    "commit": "git-cz"
  },
  "devDependencies": {
    "commitizen": "^4.2.3"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  },
  ...
}

When I use npm run commit, it gives:

$ npm run commit

> update-vue2-vite@1.0.0 commit E:\Projects\Github\boxsnake\update-vue2-vite
> git-cz

Could not resolve E:\e\Projects\Github\boxsnake\update-vue2-vite\node_modules\cz-conventional-changelog. Cannot find module 'E:\e\Projects\Github\boxsnake\update-vue2-vite\node_modules\cz-conventional-changelog'
Require stack:
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\_commitizen@4.2.3@commitizen\dist\commitizen\adapter.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\_commitizen@4.2.3@commitizen\dist\commitizen.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\_commitizen@4.2.3@commitizen\dist\cli\git-cz.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\_commitizen@4.2.3@commitizen\bin\git-cz.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\_commitizen@4.2.3@commitizen\bin\git-cz
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! update-vue2-vite@1.0.0 commit: `git-cz`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the update-vue2-vite@1.0.0 commit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Programs\nodejs\global\cache\_logs\2021-04-25T16_03_44_621Z-debug.log

PS. When I use node -e 'console.log(process.cwd())' in zsh environment, it gives Windows formatted path:

$ node -e 'console.log(process.cwd());'
E:\Projects\Github\boxsnake\update-vue2-vite
boxsnake commented 3 years ago

This is not only in zsh, I tested in cmd env, and got the same error.

Result for node -e "console.log(require.resolve('./node_modules/cz-conventional-changelog'))" in zsh is:

E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\cz-conventional-changelog\index.js