Cz-cli: Can not load ` cz-conventional-changelog` in adapter.js

Created on 15 May 2018  路  3Comments  路  Source: commitizen/cz-cli

Environments:
OS: Windows 10 (1703, OS 15063.966)
Terminal: cmd
Project Path: E:\PHPSite\Github\boxsnake-php\simple-api-ssr

package.json:

{
  "name": "simple-api-ssr.doc",
  "version": "0.0.0-doc",
  "description": "Documentation for Simple API SSR",
  "main": "index.js",
  "scripts": {
    "commit": "./node_modules/.bin/git-cz"
  },
  "repository": {
    "type": "git",
    "url": "https://boxsnake-php.github.io/simple-api-ssr/"
  },
  "keywords": [
    "docs"
  ],
  "author": "Alex Fang <[email protected]>",
  "license": "MIT",
  "devDependencies": {
    "commitizen": "^2.9.6",
    "cz-conventional-changelog": "^2.1.0"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}

Command Run:

npm run commit

Error logs:

E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr>npm run commit

> [email protected] commit E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr
> git-cz

/e/PHPSite/GitHub/boxsnake-php/simple-api-ssr
E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\commitizen\dist\commitizen\adapter.js:192
    throw error;
    ^

Error: Could not resolve E:\e\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\cz-conventional-changelog. Cannot find module 'E:\e\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\cz-conventional-changelog'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.resolve (internal/module.js:18:19)
    at resolveAdapterPath (E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\commitizen\dist\commitizen\adapter.js:189:20)
    at gitCz (E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\commitizen\dist\cli\strategies\git-cz.js:77:35)
    at Object.bootstrap (E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\commitizen\dist\cli\git-cz.js:31:27)
    at Object.<anonymous> (E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\commitizen\bin\git-cz.js:2:34)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
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:\Program Files\nodejs\node_global\cache\_logs\2018-05-15T02_12_05_098Z-debug.log

It seems parse E:\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\cz-conventional-changelog wrongly by E:\e\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\cz-conventional-changelog.

Most helpful comment

Solved.

The module path is resolved to E:\e\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\cz-conventional-changelog. It is because the config.commitizen.path is ./node_modules/cz-conventional-changelog, the path is relative path, and it is resolved from cwd.

I solved this by changing the path to cz-conventional-changelog. This path does not start with a dot (.), and it is regarded as a package. It works fine.

All 3 comments

"scripts": {
    "commit": "./node_modules/.bin/git-cz"
  },

Should change script name to 'cz' or something to avoid conflicts with husky.

Since you're using Windows, suggest that you escape backslashes in your pathname.

E:\\PHPSite\\GitHub\\boxsnake-php\\simple-api-ssr

Solved.

The module path is resolved to E:\e\PHPSite\GitHub\boxsnake-php\simple-api-ssr\node_modules\cz-conventional-changelog. It is because the config.commitizen.path is ./node_modules/cz-conventional-changelog, the path is relative path, and it is resolved from cwd.

I solved this by changing the path to cz-conventional-changelog. This path does not start with a dot (.), and it is regarded as a package. It works fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ktwbc picture ktwbc  路  5Comments

booc0mtaco picture booc0mtaco  路  4Comments

jacobq picture jacobq  路  7Comments

dealloc picture dealloc  路  5Comments

micky2be picture micky2be  路  6Comments