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

how set up nvm with oh-my-zsh to load globally installed bower, yo , grunt or jshint #635

Closed
programming-kid opened this issue Jan 28, 2015 · 18 comments

Comments

@programming-kid
Copy link

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 👍

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

@ljharb
Copy link
Member

ljharb commented Jan 28, 2015

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.

@ljharb ljharb closed this as completed Jan 28, 2015
@programming-kid
Copy link
Author

yes i did that i completely removed old node_modules and reinstall them using nvm npm

@ljharb
Copy link
Member

ljharb commented Jan 28, 2015

great, let me know if you still have any issues

@programming-kid
Copy link
Author

what i meant was i already did that but still it dosen't work

@ljharb
Copy link
Member

ljharb commented Jan 28, 2015

By default, nvm won't use any particular version. Try nvm alias default stable, and then reopen your shell?

@programming-kid
Copy link
Author

what i done till now is

  • removed old node and all node_modules
  • install nvm
  • nvm install v0.10.36
  • nvm alias default 0.10.32
  • npm install -g yo bower grunt-cli
  • added source ~/.nvm/nvm.sh to .zshrc

everything 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

@ljharb
Copy link
Member

ljharb commented Jan 28, 2015

ok so in that new session, what's which node, which npm, npm root -g, and nvm current report?

@programming-kid
Copy link
Author

▶ 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

@ljharb
Copy link
Member

ljharb commented Jan 28, 2015

Ah, npm root -g is reporting the wrong thing. Perhaps this is #606, and you have a prefix specified in ~/.npmrc?

@programming-kid
Copy link
Author

yes it says
prefix = /home/kid/local

@ljharb
Copy link
Member

ljharb commented Jan 28, 2015

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.

@programming-kid
Copy link
Author

i will try again after removing that line from ~/.npmrc and get back to you

@programming-kid
Copy link
Author

hey it worked thanks, you are awesome 👍

@ljharb
Copy link
Member

ljharb commented Jan 28, 2015

np, thanks for working through it.

@nucleardreamer
Copy link

Thank you guys for this thread, I thought I was going crazy but this helped!

@mhicauber
Copy link

Awesome - same issue here, due to previous npm install withou nvm I guess. Thanks a lot.

@anthonybrown
Copy link

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.

@ljharb
Copy link
Member

ljharb commented Jun 11, 2018

@anthonybrown what suggested "compaudit"; i've never heard of that?

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

5 participants