I have several states of global packages between my machine/server/staging. All of them use nvm, and my impression was that all the packages should be installed under it. Locally, for example, I have:
which yarn
/Users/***/.nvm/versions/node/v14.15.4/bin/yarn
It looks fine until I switch the node version selected by nvm:
nvm use v12.19.1
which yarn
/Users/***/.nvm/versions/node/v14.15.4/bin/yarn
Q1: Is it okay that yarn is installed for v14.15.4
, but is used under v12.19.1
?
On my staging/production machines I have yarn installed globally:
which yarn
~/.yarn/bin/yarn
Q2: Is it okay that yarn installed globally? Is it better than to install it under nvm?
For production, I have pm2 installed globally by yarn, while nvm is used:
which pm2
~/.config/yarn/global/node_modules/.bin/pm2
Q3: Is it okay to have it globally installed?
For staging, pm2 is installed under nvm:
which pm2
~/.nvm/versions/node/v14.15.4/bin/pm2
Q4: Is it okay to have it installed under nvm?
Q5: Which node version will be used on personal/staging/production machines for yarn/pm2 after I switch it using nvm?
Q6: Are there differences for these questions between yarn/npm (if I was using npm instead of yarn)?
question from:
https://stackoverflow.com/questions/65903313/global-installation-vs-under-nvm 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…