Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"nvm set default" vs. "nvm use" #38

Closed
Dunkelheit opened this issue Feb 17, 2016 · 4 comments
Closed

"nvm set default" vs. "nvm use" #38

Dunkelheit opened this issue Feb 17, 2016 · 4 comments

Comments

@Dunkelheit
Copy link

Hello all,

I'm having this issue since version 0.11.0 (commit 11ae323)

I work on a project that relies on different Node.js versions. My default nvm version is set to 0.10.42, and then I use nvm use to switch to the other version, v4.3.0.

However, husky will always use the default version instead of the one currently in use by nvm. Which works fine whenever I'm working on a 0.10.42 project, but won't work so smooth when I'm working on v4.3.0.

Example:

🍕 git push
npm WARN deprecated This version of npm lacks support for important features,
npm WARN deprecated such as scoped packages, offered by the primary npm
npm WARN deprecated registry. Consider upgrading to at least npm@2, if not the
npm WARN deprecated latest stable version. To upgrade to npm@2, run:
npm WARN deprecated
npm WARN deprecated   npm -g install npm@latest-2
npm WARN deprecated
npm WARN deprecated To upgrade to the latest stable version, run:
npm WARN deprecated
npm WARN deprecated   npm -g install npm@latest
npm WARN deprecated
npm WARN deprecated (Depending on how Node.js was installed on your system, you
npm WARN deprecated may need to prefix the preceding commands with `sudo`, or if
npm WARN deprecated on Windows, run them from an Administrator prompt.)
npm WARN deprecated
npm WARN deprecated If you're running the version of npm bundled with
npm WARN deprecated Node.js 0.10 LTS, be aware that the next version of 0.10 LTS
npm WARN deprecated will be bundled with a version of npm@2, which has some small
npm WARN deprecated backwards-incompatible changes made to `npm run-script` and
npm WARN deprecated semver behavior.

> [***]@2.0.0 prepush [***]
> gulp test

[12:52:25] Using gulpfile [***]/gulpfile.js
[12:52:25] Starting 'pre-test'...
[12:52:26] Finished 'pre-test' after 659 ms
[12:52:26] Starting 'test'...
dyld: lazy symbol binding failed: Symbol not found: _node_module_register
  Referenced from: [***]/node_modules/bunyan/node_modules/dtrace-provider/build/Release/DTraceProviderBindings.node
  Expected in: dynamic lookup

dyld: Symbol not found: _node_module_register
  Referenced from: [***]/node_modules/bunyan/node_modules/dtrace-provider/build/Release/DTraceProviderBindings.node
  Expected in: dynamic lookup

.git/hooks/pre-push: line 9: 35011 Trace/BPT trap: 5       npm run prepush

husky - pre-push hook failed (add --no-verify to bypass)

error: failed to push some refs to '[***]'

Is this intended functionality? If so, does anybody know of a way to solve this without having to use nvm set default all the time, instead of nvm use?

Best regards,
Arturo

@typicode
Copy link
Owner

Hi Arturo,

It's not really intended, I'll fix that.
For the moment, I would suggest keeping v0.10.

Best regards

@typicode
Copy link
Owner

Should be good now v0.11.1, husky will use .nvmrc if available:

project1$ echo 0.10 > .nvmrc
project2$ echo 4 > .nvmrc
project3$ # default Node version

Let me know if there are still problems.

@Dunkelheit
Copy link
Author

Awesome!

I've tested it and works like a charm.

Adding some debugging in .git/hooks/pre-push:

echo Before: `node -v`
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && [ -f .nvmrc ] && nvm use
echo After: `node -v`

Result:

🍕 git push
Before: v4.3.0
Found '[***]/.nvmrc' with version <4.3.0>
Now using node v4.3.0 (npm v2.14.12)
After: v4.3.0

> [***]@2.0.0 prepush [***]
> gulp test

Thanks a lot! 👍

@typicode
Copy link
Owner

Great :) you're welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants