It is a bit strange that on my MacBook Air, npm installed yarn on
$ which yarn
/Users/peter/.npm-global/bin/yarn
but on my other iMac, it is installed on a "per Node version folder":
$ which yarn
/Users/peterimac/.nvm/versions/node/v16.0.0/bin/yarn
Which one is more correct, and should I and how do I adjust the other Mac back to the "correct" mode? But on the iMac, it is strange that if I do
yarn use 16
yarn build
and then it says to use yarn global add serve and then serve -s build but it kept on saying serve does exist no matter how I source ~/.profile and source ~/.zprofile. I have to npm i -g serve for it to exist.
Also, on the first Mac, the yarn and serve also do not need to be installed for any different versions of Node. The same version of yarn and serve seemed to be used no matter which version of Node I change to using nvm use 14 or nvm use 16. So I am not sure if this is the correct behavior.
Is one Mac more correct than the other, and how to fix it back to the correct way and what about the serve not installed issue?
I found part of the answer: if your
yarnis atthat means some time in the past, you have set
.npm-globalto be a one and only path... and that would conflict withnvm. So remove that line from your~/.npmrc, and also remove the.npm-globaltext or line from your~/.profile, and.zprofile,.bashrc,.zshrc, if any.