cz-cli icon indicating copy to clipboard operation
cz-cli copied to clipboard

path resolve failed on MSYS2+zsh environment

Open boxsnake opened this issue 3 years ago • 1 comments

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

> [email protected] 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\[email protected]@commitizen\dist\commitizen\adapter.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\[email protected]@commitizen\dist\commitizen.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\[email protected]@commitizen\dist\cli\git-cz.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\[email protected]@commitizen\bin\git-cz.js
- E:\Projects\Github\boxsnake\update-vue2-vite\node_modules\[email protected]@commitizen\bin\git-cz
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] commit: `git-cz`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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 avatar Apr 25 '21 16:04 boxsnake

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

boxsnake avatar Apr 25 '21 17:04 boxsnake