Volver

Bower – Cannot be run with sudo

If you can’t get bower working and you get the following error

# bower install foo
bower ESUDO Cannot be run with sudo

The problem is that while bower won’t run with sudo, it also won’t run if you are logged in as root. One solution would be using the –allow-root flag:

# sudo bower --allow-root

That won’t work if it is a script someone else has written which is complaining (as if often the case using Docker, for example). In that case, you should set the global bower config that will allow running bower as root, ensuring that the following command is run before bower:

# echo '{ "allow_root": true }' > /root/.bowerrc

This will create the file: /root/.bowerrc which will have inside the following configuration:

{ "allow_root": true }

If you can explore more possibilities of Bower, click here.

Leave a Reply

Your email address will not be published. Required fields are marked *