nonopolarity
nonopolarity

Reputation: 150976

nvm installing yarn either on a Node version folder or in one folder regardless of Node version?

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?

Upvotes: 0

Views: 4179

Answers (1)

nonopolarity
nonopolarity

Reputation: 150976

I found part of the answer: if your yarn is at

/Users/peter/.npm-global/bin/yarn

that means some time in the past, you have set .npm-global to be a one and only path... and that would conflict with nvm. So remove that line from your ~/.npmrc, and also remove the .npm-global text or line from your ~/.profile, and .zprofile, .bashrc, .zshrc, if any.

Upvotes: 1

Related Questions