How to install ionic in ubuntu Desktop 16.04.LTS

Node and npm are a very complex package management ecosystem. In a manner of speaking, it is almost as if you are installing something as comprehensive as a separate OS. When you run npm with elevated privileges, you are effectively entangling the npm OS with your underlying OS, because npm is going to write a bunch of files in places that are hard to even track, let alone corral. Once you run npm under sudo even once, then you have committed yourself to doing it every time.

The primary reason I am so emphatic about using nvm instead of sudo is this: now and again, something goes sideways. It happens to all of us. If you regularly read support forums like this, you will see countless examples.

You can fastidiously use strace to try to find all of the tens of thousands of files that npm is looking for when you run a problematic command. You can hunt them all down, theorize about conflicts, scour the internet in the hope that somebody else out there happened to have just exactly the same problem you do. If that all turns out to be fruitless, your only real recourse is to completely vaporize your OS and install from scratch. Maybe next time you’ll do your node work inside a VM, so that OS is walled off from your host OS containing all your personal stuff that is such a pain to keep restoring from backups.

Or, you could just avoid doing any of that and type:

$ nvm uninstall <version>
$ nvm install <version>

The choice seems crystal clear to me.

1 Like