More or less, although I would phrase it this way: whenever you run anything as root, you’re completely at the mercy of whoever wrote it as far as what gets modified where on the system. This is why I rail so persistedly about people recommending sudo
, and it sounds like you literally did have to pretty much reinstall your OS.
Again more or less yes, but to elaborate: if you do run into issues once nvm
is in charge, it’s a one-liner to switch node environments, or get a completely clean one with:
$ nvm uninstall --lts
$ nvm install --lts
$ npm i -g ionic @angular/cli whatever-other-global-npm-things-you-use
In a catastrophic scenario, everything nvm uses sits in the .nvm folder of your home directory, which can be manually removed. And since it’s in home directories, your strategy of using different OS users will become feasible (although I doubt you’ll need to resort to it).
It would be cleanest to uninstall the package-manager stuff, in case you have priority problems with PATH
, but I think nvm is engineered to deal with this situation and should properly get its stuff ahead of package-manager-installed node. But no, you don’t have to install node locally in each project. Cordova is a bit like Ionic in the sense that it has a “global” CLI and local bits. The locally-needed bits are probably already in your various projects, and the global bits will become managed by nvm like Ionic’s CLI will.
After following the steps in here to get nvm itself running,
$ nvm install --lts
$ which node
…check that it’s something under your home directory, not /usr or /usr/local or /brew/whatever (it’s been a long time since I’ve done anything with Node on MacOS without the nvm safety blanket)
$ npm i -g ionic cordova @angular/cli
$ which ionic
…should also be somewhere underneath your home directory.
$ ionic -v
…should be 5.4.something as I write this.