First of all my apologizes , i know this question might have been asked so many times in here and all over INTERNET, which has caused much more confusion to this problem, i tried many solutions but none worked so finally, I created this issue, which may also serve as wiki for future users.
Uptil today i used node v0.10.26 which was released over an year ago, but today i decide to upgrade my node version.
I had previously installed node from source which is why i didn't update it for so long, so this time i decided to use nvm , it was super easy to use nvm :+1:
But quickly after installing i noticed one problem i couldn't execute my globally installed packages like yo or bower, i google alot and came up with so many useless solutions , i knew it has something to do with .bashrc or .profile or .zshrc but couldn't fix it i have appended following to all above files
export NVM_DIR="/home/sohan/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
source ~/.nvm/nvm.sh
so i finally i tried one trick
first i opened bash from terminal and i again opend zsh from terminal which solved my problem only temporarily for that session , i had to do thins whenever i opened new session
This was fine as i can live with this for sometime but when i opened sublime3 i couldn't load jslint or jshint, which is when i started digging more to fix this problem because i cannot live without those two plug-in
pls help me fix this problem
thanks
Your original globally installed packages must be reinstalled in the nvm node version you have installed.
What you probably want to do is to run nvm reinstall-packages system, or manually npm install -g whichever one you want.
yes i did that i completely removed old node_modules and reinstall them using nvm npm
great, let me know if you still have any issues
what i meant was i already did that but still it dosen't work
By default, nvm won't use any particular version. Try nvm alias default stable, and then reopen your shell?
what i done till now is
source ~/.nvm/nvm.sh to .zshrceverything is fine till here
node -v ---> v 0.10.36
npm -v ---> 1.4.28
i get node and npm when i open new session but i dont get bower or yo or grunt
ok so in that new session, what's which node, which npm, npm root -g, and nvm current report?
â–¶ which node
/home/kid/.nvm/v0.10.36/bin/node
~
â–¶ which npm
/home/kid/.nvm/v0.10.36/bin/npm
~
â–¶ npm root -g
/home/kid/local/lib/node_modules
~
â–¶ nvm current
v0.10.36
Ah, npm root -g is reporting the wrong thing. Perhaps this is #606, and you have a prefix specified in ~/.npmrc?
yes it says
prefix = /home/kid/local
That's the problem. Remove that line until #606 is resolved, and reinstall your global modules :-)
Or, put /home/kid/local in your PATH, but nvm won't be happy about that.
i will try again after removing that line from ~/.npmrc and get back to you
hey it worked thanks, you are awesome :+1:
np, thanks for working through it.
Thank you guys for this thread, I thought I was going crazy but this helped!
Awesome - same issue here, due to previous npm install withou nvm I guess. Thanks a lot.
what to do if you can't run any commands?
I just installed some versions of node with nvm and got an error about permissions
so I ran what was suggested compaudit | xargs chmod g-w,o-w
now when I quit iterm and restart, it won't load and I can't do anything except quit and open new tabs?
Nothing like this has ever happened before.
@anthonybrown what suggested "compaudit"; i've never heard of that?
Most helpful comment
Thank you guys for this thread, I thought I was going crazy but this helped!