在使用 bower 安裝依賴包時有時會出現「permission denied」權限不足的問題,這時咱們會想到用sudo,以root權限安裝,但sudo後問題來了,又出現了」Cannot be run with sudo」問題。報錯信息以下:python
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]看下幫助信息:sql
$ bower --help ... --allow-root Allows running commands as root ...
幫助信息裏有這個設置項,那麼咱們就來試一下:spa
$ sudo bower install //報錯 //添加參數繼續試 $ sudo bower install --allow-root // 成功執行
Ok,問題已經解決了。bower