46

I get the following error when I run bower:

bower ESUDO Cannot be run with sudo

Thing is, I'm not running bower with sudo. The command I run is:

bower install foo

or

bower search cats

I am logged in as root to an Ubuntu 12.04 server but I am not using sudo. What gives? How do I get bower working?

  • Please consider updating the accepted answer. – Binyomin Trager Mar 5 '14 at 17:52
78

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

See this issue.

| improve this answer | |
29

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

| improve this answer | |
  • In my case, I had to do echo '{ "allow_root": true }' > ~/.bowerrc which is probably more flexible. – Johannes Brodwall Aug 1 '18 at 9:16
5

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.

| improve this answer | |
2

Use the --allow-root flag:

sudo bower --allow-root <comand> 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.