Cz-cli: Can't commit: nvm is not compatible with the "npm_config_prefix" environment variable

Created on 3 Feb 2018  路  4Comments  路  Source: commitizen/cz-cli

I have a project that was using commitizen without problems. I've decided to add husky to run precommit hooks with prettier. The problem is that when I run the 'npm run cm' command, I get this error...

? Are there any breaking changes? No
? Does this change affect any open issues? No
nvm is not compatible with the "npm_config_prefix" environment variable: currently set to "/Users/aiglesias/.nvm/versions/node/v8.9.4"
Run `unset npm_config_prefix` to unset it.
.git/hooks/pre-commit: line 49: node: command not found
husky > npm run -s precommit (node )

env: node: No such file or directory

husky > pre-commit hook failed (add --no-verify to bypass)
/Users/aiglesias/Coding/react/react-basesupsub/node_modules/commitizen/dist/cli/strategies/git-cz.js:102
        throw error;
        ^

Error: git exited with error code 1
    at ChildProcess.<anonymous> (/Users/aiglesias/Coding/react/react-basesupsub/node_modules/commitizen/dist/git/commit.js:50:26)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] cm: `git-cz`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] cm 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!     /Users/aiglesias/.npm/_logs/2018-02-03T08_22_42_663Z-debug.log

I've removed prettier and try just husky and a basic 'npm run test' precommit hook, with the same error. Obviously, I see the message, but I don't know if running unset npm_config_prefix can cause me bigger problems in other places.

Most helpful comment

@pedro-mass Yes. You just have to install the beta version of husky (npm install husky@next --save-dev). No problems so far.
I hope it helps

All 4 comments

More info...

  • Neither $NPM_CONFIG_PREFIX nor $PREFIX are set in my environment.
  • I've tried unset npm_config_prefix, but with the same results.
  • Also tried remove it with nvm use --delete-prefix v8.9.4, npm config delete prefix and nvm use --delete-prefix v8.9.4 --silent, with same results.
  • I've also tried to overwrite it using npm config set prefix $NVM_DIR/versions/node/v8.9.4, and no changes.
  • Uninstalling and installing node. Same error.

What is driving me crazy is that I'm only having nvm/npm issues here (at least I haven't detected in any other place), and I can't see where is this coming from.

I've just realized it makes no sense to open this issue here, because looks like the commitizen part is executed, the problem arises when husky tries to run the hook, so I'm moving this to husky.

Sorry for the inconvenience

@rigobauer ever find a solution? Doing something similar, husky works with a regular commit; but not with cz-cli

@pedro-mass Yes. You just have to install the beta version of husky (npm install husky@next --save-dev). No problems so far.
I hope it helps

Was this page helpful?
0 / 5 - 0 ratings