我正在制作一个使用twitter的bower的新项目 . 我创建了一个 component.json
来维护我的所有依赖,比如jquery . 然后我运行 bower install
,将所有内容安装在名为 components
的文件夹中 . 但我需要将组件安装在不同的文件夹中,例如 public/components
.
我已经尝试将components.json编辑成:
{
"name": "test",
"version": "1.0.0",
"directory": "public/",
"dependencies": {
"jquery": "*"
}
}
要么:
{
"name": "test",
"version": "1.0.0",
"componentsDirectory": "public/",
"dependencies": {
"jquery": "*"
}
}
如https://github.com/twitter/bower/pull/94所示,但它不起作用 .
7 回答
值得一提的东西......
如上面其他贡献者所述,使用带有JSON的
.bowerrc
文件{ "directory": "some/path" }
是必要的 - 但是,在创建该文件时,您可能会在Windows上遇到问题 . 如果Windows为您提供了一条消息,要求您添加“文件名”,只需使用文本编辑器/ IDE(如记事本)即可 .
将JSON添加到未命名的文件中,将其保存为.bowerrc - 您很高兴!
可能是一个简单的假设,但我希望这能为其他人节省不必要的麻烦:)
我在Windows 10上遇到了同样的问题 . 这就解决了我的问题
在根文件夹中删除
bower_components
在根目录中创建
.bowerrc
文件在文件中写这段代码
{"directory" : "public/bower_components"}
运行
bower install
您现在应该在公用文件夹中看到bower_components文件夹
从根目录删除组件文件夹 .
在根目录中创建一个(.bowerrc)文件(如果是linux,这是一个隐藏文件)
在此文件(.bowerrc)中编写以下代码
{“directory”:“public / components”}
运行命令:bower install
您现在应该在公用文件夹中看到components文件夹
除了编辑
.bowerrc
以设置默认安装路径之外,您还可以为不同的文件类型设置自定义安装路径 .有一个名为bower-installer的节点包,它提供了一个用于管理备用安装路径的命令 .
运行
npm install -g bower-installer
设置你的bower.json
运行以下命令:
bower-installer
这将
components/jquery-ui/themes/start/jquery-ui.css
安装到./src/css
等使用内容在项目根目录(而不是主目录)中创建Bower configuration file .bowerrc:
再次运行
bower install
.嗨,我是同样的问题,并解决这个问题 .
Windows用户和vs cant'create .bowerrc文件 .
在cmd中去任何文件夹
安装任何包含.bowerrc文件的包 . 例如
这个插件包含.bowerrc文件 . 复制并转到您的项目并粘贴此文件 .
在visual studio中 - 解决方案资源管理器 - 显示所有文件并包含项目看到的.bowerrc文件
我解决这个问题:)
尝试将
components.json
文件放在应用程序的public
目录中,而不是根目录,然后重新运行bower install
...在您的应用主目录中试试这个: