I can't begin to use commitizen globally in my Windows.
D:\SashaBranchReleaseIt>npm install -g commitizen
C:\Users\SashaChernykh\AppData\Roaming\npm\git-cz -> C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\bin\git-cz
C:\Users\SashaChernykh\AppData\Roaming\npm\commitizen -> C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\bin\commitizen
+ [email protected]
updated 1 package in 8.143s
D:\SashaBranchReleaseIt>npm install -g cz-conventional-changelog
+ [email protected]
updated 1 package in 1.217s
D:\SashaBranchReleaseIt>echo %HOME%
C:\Users\SashaChernykh
I create a file .czrc in C:\Users\SashaChernykh directory. It content:
echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc
I run git cz command in any my git repository.
Successful usage commitizen.
D:\SashaBranchReleaseIt>git cz
C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\dist\configLoader\getContent.js:56
throw error;
^
SyntaxError: Parsing JSON at C:\Users\SashaChernykh\.czrc for commitizen config failed:
at JSON.parse (<anonymous>)
at C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\dist\configLoader\getContent.js:40:17
at readConfigContent (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\dist\configLoader\getContent.js:46:18)
at getConfigContent (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\dist\configLoader\getContent.js:78:17)
at loader (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\dist\configLoader\loader.js:62:56)
at Object.load (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\dist\commitizen\configLoader.js:17:35)
at Object.bootstrap (C:\Users\SashaChernykh\AppData\Roaming\npm\node_modules\commitizen\dist\cli\git-cz.js:26:70)
at Object.<anonymous> (C:\Users\SashaChernykh\AppData\Roaming\npm\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)
Thanks.
I'm sorry, stupid error.
Valid .czrc content is:
{ "path": "cz-conventional-changelog" }
Thanks.
I made stupid mistakes, too.
What is the difference?
Try deleting ~/.czrc then putting this in it:
{ "path": "cz-conventional-changelog" }
The .czrc file content is: { "path": "cz-conventional-changelog" }. it is still throw error, why?
I fixed it . I delete .czrc file and create new one by VScode.
.czrc file content:
{ "path": "cz-conventional-changelog" }
The difference is the charset. echo in Powershell produce .czrc with UTF-16, but UTF-8 is expected. So create .czrc manually with the same content works.
Hmm, maybe load-json-file would have given better error messages. Anyone up for a PR? ☺️ 🙌
@LinusU load-json-file not works.
According to the source code , index.js#L19 ,
module.exports = (filePath, options) => pify(fs.readFile)(filePath, 'utf8').then(data => parse(data, filePath, options));
module.exports.sync = (filePath, options) => parse(fs.readFileSync(filePath, 'utf8'), filePath, options);
It reads content with UTF-8charset instead of UTF-16.
It will throw JSONError during parse, but the error message is not clear.
\node_modules\[email protected]@parse-json\index.js:31
throw jsonErr;
^
JSONError: Unexpected token � in JSON at position 0 while parsing near '��{
same question , thanks
Most helpful comment
I'm sorry, stupid error.
Valid
.czrccontent is:Thanks.