sudo is required for all Ionic and Cordova commands

Aug 26, 2015 · Follow on Twitter and Mastodon archive

I’m currently building my first Ionic Framework app. It’s fast to setup and performs well, but I ran into a problem that forces me to use sudo for all Ionic & Cordova commands.

This problem only occurs at work, not at home. I understand that some global commands require sudo, but at work I also have to use sudo for commands like:

  • ionic platform add android
  • ionic build ios
  • ionic run android

If I don’t use sudo, Ionic isn’t able to remove assets in the platform folders. I can also not open the project in Xcode, due to missing permissions.

I finally found a terminal command that fixes these problems whenever they happen:

sudo chown -R $(whoami) ~/<path to your project folder>

Run it, and you will no longer have to use sudo when running Ionic & Cordova commands. You will also be able to open the Xcode project without warnings.

Discussions & More

Please share any ideas, feedback or comments you may have in the Disqus section below, or by replying on Twitter or Mastodon.

If you found this text interesting, make sure to follow me on Twitter and Mastodon for more content like this, and to be notified when new content is published.

If you like & want to support my work, please consider sponsoring me on GitHub Sponsors.