-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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 use" not persisting #658
Comments
You can either do |
I don't understand. It's not persisting at all, let alone for the lifetime of the shell. Please read the issue again: This is all one shell: $ nvm current
v0.12.0
$ nvm install 0.10
######################################################################## 100.0%
Now using node v0.10.36
$ nvm current # NOTE: didn't change
v0.12.0
$ node -v
v0.12.0
$ nvm use 0.10
Now using node v0.10.36
$ nvm current
v0.12.0
$ node -v
v0.12.0
$ nvm install iojs
######################################################################## 100.0%
WARNING: checksums are currently disabled for io.js
Now using io.js v1.2.0
$ nvm current
iojs-v1.2.0
$ node -v # NOTE: didn't change AND different from nvm current
v0.12.0 You may have been confused by this comment:
In other words, it works as intended within sudo, but not in my regular shell. |
Ah, sorry, responding too quickly :-) What does |
Also, how did you install |
$ which node
/home/yourdeveloperfriend/.nvm/versions/node/v0.12.0/bin/node
$ echo $PATH
/home/yourdeveloperfriend/.nvm/versions/node/v0.12.0/bin:/home/yourdeveloperfriend/.rbenv/plugins/ruby-build/bin:/home/yourdeveloperfriend/.rbenv/shims:/home/yourdeveloperfriend/.rbenv/bin:/usr/local/heroku/bin:/home/yourdeveloperfriend/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/yourdeveloperfriend/.rvm/bin:~/www/phantomjs/bin:/home/yourdeveloperfriend/.rvm/bin
$ which iojs # no response.
$ npm root -g
/home/yourdeveloperfriend/.nvm/versions/node/v0.12.0/lib/node_modules I installed nvm via my one user: yourdeveloperfriend. I installed with the install script: |
And don't worry about closing the issue too quickly, I understand you guys probably have a lot of garbage to sort through. Thanks for your help. |
@YourDeveloperFriend When you're in the above situation (where 0.10 and 0.12 are installed, 0.12 is active, and |
$ nvm deactivate
/home/yourdeveloperfriend/.nvm/*/bin removed from $PATH
/home/yourdeveloperfriend/.nvm/*/share/man removed from $MANPATH
$ which node
/usr/local/bin/node
$ node -v
0.12.0 |
This is very confusing :-) so, when you start with The only thing I can thing of is that somewhere in that chain, the What's the output of |
That was it! I had an alias in my |
ah HA! Yay, thanks for working through it with me! If you originally installed |
So should I uninstall |
Yes, absolutely. It won't cause problems, but as we've seen it could definitely cause confusion :-) |
Just a not to say that I had been struggling with this for a long time on ubuntu and removing (In pre- |
I'm experiencing this same issue with the latest nvm ( I have node installed in my system, ran the nvm install script, set the
nvm is installed and behaving normally except that the new shell sessions always revert to the system version of node. Am I missing something? |
@thelostspore let's debug here for a moment - can you gist the output of |
Thanks @ljharb Output of
I think its worth mentioning that I first attempted install via the Also, I placed an |
|
Ok, uninstalled
The |
ok so |
I don't think the
Same results with |
aha! @thelostspore try |
Ok, removed all aliases (I definitely tried
|
great, and inside |
Only |
ok - so just to confirm once more: new shell, |
FWIW I had to delete pretty sure this was a side effect of having installed via brew. I uninstalled via brew and installed via the also kudos @ljharb for being helpful AF |
That |
@wq1308786830 windows nvm isn't this project; that's |
@ljharb thanks |
use |
Having similar problems as some other users above and have tried all suggestions given but I'm still seeing some unexpected behavior. I'm on mac os with zsh, installed properly from the readme and most behaviors work as intended, except when I source my zshrc file.
I should also add that if afterwards I use Here is whats in my zshrc that seems relevant: |
The "prefix" error is the issue; do you have an |
I do not have a Also I'm very impressed with your response time and the previous responses you've given. Thank you! |
@JonahMoses would you mind filing a new issue for this one? I assume that at the end of that screenshot, |
For me when I do This trick work for me, goto Thanks |
@anjum121 that suggests that the permissions on that file aren't correct; such that |
|
This is sort of a fix when using Yarn. many people suggest it to get rid of issues with node/nodejs naming problems with packages and using yarn. |
The only thing that should ever care about “nodejs” is ubuntu’s broken (for node) default repository; it shouldn’t ever be required. |
How can I run a node script to change environment? const {execSync} = require('child_process');
execSync('. ~/.nvm/nvm.sh && nvm use v12.9.1', {encoding: 'utf8'});
execSync('npm version', {encoding: 'utf8'}); // => try to use [email protected] Even if: execSync('. ~/.nvm/nvm.sh && node build.js'); // cannot use nvm within build.js But actually it does not work, and how can I do this? |
@aleen42 you pretty much can't. nvm is a sourced shell function, so it's only usable within the same shell session you sourced nvm.sh in. In your example, you'd have to combine every v12.9.1 command into the same |
this didn't work for me on circleci. the only way that I could get it to work was by uninstalling the version of node that the circleci image shipped with. the default alias was then respected by new shells/run steps as expected |
Hi guys, reading through the above, it isn't entirely clear if there was a solution to this, at least for Ubuntu/Linux latest versions. |
@markcollinscope this specific issue was caused by trying to alias node to “nodejs”. If you have a different problem, please file a new issue and fill out the full issue template. |
Finally, we have used a standalone docker image to build up CI and using environment parameters to specify the node version with nvm when starting up a pipeline. |
@markcollinscope How are you loading nvm into your shell? export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion to my |
@LuuchoRocha - thank you for your input. I will check this out and get back to you to let you know. Appreciated! |
Unfortunately, this seems broken, at least on linux: My aliases: nvm ls
v16.20.0
-> v18.16.0
default -> 16.20.0 (-> v16.20.0)
node -> default (-> v16.20.0)
stable -> default (-> v16.20.0)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/hydrogen (-> v18.16.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.0
lts/hydrogen -> v18.16.0 You will notice that 18 is active even though both the My export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion Linux Kernel: uname -r
6.2.10-300.fc38.x86_64 In order for my preference for 16 to persist across session, I had to |
@baughmann what version of nvm do you have? |
@ljharb I pointed |
In case this helps anyone else: I was struggling with this and could not get After doing a simple |
Sorry, I'm sure this is a duplicate, but I can't find anything in the miriad of issues. I'm running on Ubuntu 14.04, nvm version 0.23.3, and I just recently installed nvm. I used to be on
n
but I switched here in order to try out iojs, so it's possible that some residualn
is conflicting with nvm. I removed all the node versions withn
except 0.12.0, uninstalledn
, installednvm
, and I properly sourced nvm as mentioned in issue #394. Then I ran into the following issue:This all works just fine when run in
sudo su
, but when I exit that shell, it doesn't permeate.More possible clues:
$ nvm run 0.10 -v Running node v0.10.36 v0.12.0 $ nvm exec 0.10 node -v Running node v0.10.36 v0.10.36 $ nvm run iojs -v Running io.js v1.2.0 v1.2.0
Not sure how to proceed.
The text was updated successfully, but these errors were encountered: