且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 root 用户运行 bower,这可能吗?如何?

更新时间:2023-12-06 12:02:46

下面的答案是针对 symfony 框架的 bundle,但如果您从 google 来到这里,使用短语bower root",您有两种选择来解决这个问题:

below answer is for symfony framework's bundle, but if you come here from google using phrase "bower root" you have two options to solve that:

  1. 在命令中添加 --allow-root
  2. 设置全局凉亭配置,将允许以 root 身份运行 Bower

选项 1:您可以通过键入以下内容以 root 身份运行 bower:

Option 1: you can run bower as root by typing:

bower install --allow-root

通过设置--allow-root命令参数允许root

root is allowed by setting --allow-root command parameter

选项 2: 使用允许 root 的全局设置,通过创建文件:/root/.bowerrc其中有以下配置:

Option 2: is using global setting that allows root, by creating file: /root/.bowerrc which have inside following configuration:

{ "allow_root": true }

如何在 SpBowerBundle symfony 包中执行此操作:
可能您还没有在 SpBowerBundle 配置中将 sp_bower.allow_root 设置为 true


how to do this in SpBowerBundle symfony bundle:
probably you haven't set sp_bower.allow_root to true in SpBowerBundle config

在捆绑配置中,默认情况下您已设置如下:

in bundle config, by default you have set something like this:

allow_root: false # optional

但你应该有:

allow_root: true

所以在 app/config/config.yml 添加这个包配置

so in app/config/config.yml add this bundle config

sp_bower:
    allow_root: false # optional

捆绑配置参考(所有设置):https://github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md

bundle config reference (all settings): https://github.com/Spea/SpBowerBundle/blob/master/Resources/doc/configuration_reference.md