bower安装报错”Cannot be run with sudo”解决办法

在使用bower安装依赖包时有时会出现“permission denied”权限不足的问题,这时我们会想到用sudo,以root权限安装,但sudo后问题来了,又出现了”Cannot be run with sudo”问题。报错信息如下:

Since bower is a user command, there is no need to execute it with superuser permissions. If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.

这里提到“bower是一个用户命令,没有必要使用超级管理员权限”,这就奇怪了,那么我们再来通过[bower –help]看下帮助信息:

$ bower --help
--allow-root            Allows running commands as root


$ sudo bower install

$ sudo bower install --allow-root
// 成功执行




您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>