Can't get bower working - bower ESUDO Cannot be run with sudo

I had the same problem. All you have to do is add --allow-root to your command.

See this issue.


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 ensure that the following command is run before bower:

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

See here for a more in-depth explanation: https://stackoverflow.com/questions/25672924/run-bower-from-root-user-its-possible-how


The problem was that while bower won't run with sudo, it also won't run if you are logged in as root. You have to create a user and login with that in order to get it to work.


Use the --allow-root flag:

sudo bower --allow-root <comand>