我正在制作一个使用twitter的bower的新项目.我创建了一个component.json像jquery一样维护我所有的依赖.然后我运行bower install它将所有内容安装在一个名为的文件夹中components.但我需要在不同的文件夹中安装组件,例如public/components.
我已经尝试将components.json编辑成:
{
"name": "test",
"version": "1.0.0",
"directory": "public/",
"dependencies": {
"jquery": "*"
}
}
Run Code Online (Sandbox Code Playgroud)
要么:
{
"name": "test",
"version": "1.0.0",
"componentsDirectory": "public/",
"dependencies": {
"jquery": "*"
}
}
Run Code Online (Sandbox Code Playgroud)
如https://github.com/twitter/bower/pull/94所示,但它不起作用.
Ada*_*han 929
使用内容在项目根目录(而不是主目录)中创建Bower配置文件.bowerrc:
{
"directory" : "public/components"
}
Run Code Online (Sandbox Code Playgroud)
再跑bower install一次.
lfe*_*445 76
除了编辑.bowerrc以设置默认安装路径之外,您还可以为不同的文件类型设置自定义安装路径.
有一个名为bower-installer的节点包,它提供了一个用于管理备用安装路径的命令.
跑 npm install -g bower-installer
设置你的bower.json
{
"name" : "test",
"version": "0.1",
"dependencies" : {
"jquery-ui" : "latest"
},
"install" : {
"path" : {
"css": "src/css",
"js": "src/js"
},
"sources" : {
"jquery-ui" : [
"components/jquery-ui/ui/jquery-ui.custom.js",
"components/jquery-ui/themes/start/jquery-ui.css"
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
运行以下命令: bower-installer
这将安装components/jquery-ui/themes/start/jquery-ui.css到./src/css等
Tim*_*ere 58
我在Windows 10上遇到了同样的问题.这就解决了我的问题
bower_components在根文件夹中删除.bowerrc在根目录中创建一个文件{"directory" : "public/bower_components"}bower install您现在应该在公用文件夹中看到bower_components文件夹
Cod*_*ody 23
如上所述,其他贡献者使用.bowerrc带有JSON 的文件
{ "directory": "some/path" }
是必要的 - 但是,在创建该文件时,您可能会在Windows上遇到问题.如果Windows给您一条消息,要求您添加" 文件名 ",只需使用文本编辑器/ IDE,如Notepad ++.
将JSON添加到未命名的文件中,将其保存为.bowerrc - 您很高兴!
可能是一个简单的假设,但我希望这可以节省其他不必要的头痛:)
尝试将components.json文件放在public应用程序的目录中,而不是根目录,然后重新运行bower install...在您的应用程序主目录中尝试此操作:
cp components.json public
cd public
bower install
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
209908 次 |
| 最近记录: |