I have a git project which contains a bower.json file which contains several dependencies. It looks like this:
//module1
"dependencies": {
"devbridge-autocomplete": "devbridge/jQuery-Autocomplete#~1.2.21",
"backbone": "~1.2.1",
"underscore": "~1.8.3",
"jquery": "~2.1.4",
"module2": "gitUser/module2",
"module3": "gitUser/module3"
}
problem is when I run bower install --save gitUser/module1 bower does not pull the latest commits from github, and only pulls the initial commit.
bower.json of module2 and 3 are essentially similar:
{
"name": "module2",
"main": "module2.js",
"version": "0.0.0",
"authors": [
"gitUser <gitUser#gitUser.com>"
],
"moduleType": [
"amd"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"directory/bower_components",
"test",
"tests"
]
}
the cloned repositories hidden .bower.json looks like:
{
"name": "module2",
"_cacheHeaders": {
"Content-Type": "text/html; charset=utf-8"
},
"main": "index",
"_source": "https://github.com/gitUser/module2",
"_target": "*",
"_originalSource": "https://github.com/gitUser/module2"
}
I have also unsuccessfully tried installing dependencies in module1 by:
bower install --save gitUser/module2#latest
I have also tried adding git tags to each sub module, but this also did not work.
I saw this issue, so the tagging should not matter.
Any assistance appreciated!
If you want the latest commit from a specific branch:
bower install --save gitUser/module2#specific_branch_name
If you want a specific commit:
bower install --save gitUser/module2#specific_commit_id
Related
Having this in bower.json
{
"name": "test",
"dependencies": {
"jquery": "2.2.4",
"html5shiv": "3.6.2"
}
}
and running
bower install
bower installing not this versions but the latest ones (jquery 3.0.0-rc1 & html5shiv 3.7.3 as for now). Why so? I don't have any other dependencies which can require the newest versions.
This is bower install log
bower cached https://github.com/jquery/jquery-dist.git#2.2.4
bower validate 2.2.4 against https://github.com/jquery/jquery-dist.git#2.2.4
bower cached https://github.com/aFarkas/html5shiv.git#3.6.2
bower validate 3.6.2 against https://github.com/aFarkas/html5shiv.git#3.6.2
bower install jquery#2.2.4
bower install html5shiv#3.6.2
jquery#2.2.4 bower_components\jquery
html5shiv#3.6.2 bower_components\html5shiv
And it's strange for me that .bower.json for html5shiv looks like this
{
"name": "html5shiv",
"version": "3.6.2",
"main": [
"dist/html5shiv.js"
],
"ignore": [
"**/.*",
"composer.json",
"test",
"build",
"src",
"build.xml"
],
"homepage": "https://github.com/aFarkas/html5shiv",
"_release": "3.6.2",
"_resolution": {
"type": "version",
"tag": "3.6.2",
"commit": "f65f9b0d776ae3b88d4c7f0b27c64e384aee47aa"
},
"_source": "https://github.com/aFarkas/html5shiv.git",
"_target": "3.6.2",
"_originalSource": "html5shiv"
}
but bower.json looks like this
{
"name": "html5shiv",
"version": "3.7.3",
"main": [
"dist/html5shiv.js"
],
"ignore": [
"**/.*",
"composer.json",
"test",
"build",
"src",
"build.xml"
]
}
The same is for jQuery. .bower.json referencing the version that I want, but bower.json referencing the latest version. And like I said, source and dist files are from the latest version.
you should use the # before the version
for example
{
"name": "test",
"dependencies": {
"jquery": "#2.2.4"
}
}
You can find more about bower here
I have tired to change bower default folder. I have created two files
1. .bowerrc.json
2. bower.json
The content of .bowerrc.json file
{
"directory": "Vendors"
}
and the content of bower.json file
{
"name": "Sardar",
"description": "Human Resource Management System",
"main": "index.html",
"moduleType": [],
"keywords": [
"AngularJS"
],
"authors": [
"Md. Shohel Rana"
],
"license": "Restrict",
"homepage": "",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "^2.2.0"
}
}
Both are same root. when I run the command bower install that installs everything in a folder named bower_components. but need install into Vendors folder that is not working. Thanks for the time being.
just remove .json extension from the file .bowerrc.json
and again run bower install
So I have a pretty bogstandard bower.json file in a github repo:
{
"name": "backbone-iobind",
"description": "Bind socket.io events to backbone models & collections. Also includes a drop-in replacement for Backbone.sync using socket.io.",
"homepage": "https://github.com/soniflow/backbone.iobind",
"keywords": [
"model",
"view",
"controller",
"router",
"server",
"client",
"browser",
"socketio",
"socket",
"iobind"
],
"author": "Noveo Group - Forked by Matt Fletcher",
"repository": {
"type": "git",
"url": "git://https://github.com/soniflow/backbone.iobind.git"
},
"dependencies": {
"backbone": "~1.1.2"
},
"version": "0.4.8",
"main": [
"dist/backbone.iobind.js",
"dist/backbone.iosync.js"
],
"authors": [
"Matt Fletcher <matt#soniflow.com>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
... and my dependencies are straight-forwards:
"dependencies": {
"marionette": "~2.0.2",
"backbone-io": "git://github.com/Soniflow/backbone.iobind.git"
}
However, when I do bower install, it copies all the files down as it should, but for some reason ignores my bower.json file and instead creates a .bower.json like so:
{
"name": "backbone-io",
"homepage": "https://github.com/Soniflow/backbone.iobind",
"version": "0.4.8",
"_release": "0.4.8",
"_resolution": {
"type": "version",
"tag": "0.4.8",
"commit": "5e06d99d3e79b02bd8a892e3c6ba969e47f49736"
},
"_source": "git://github.com/Soniflow/backbone.iobind.git",
"_target": "*",
"_originalSource": "git://github.com/Soniflow/backbone.iobind.git"
}
... which doesn't contain any of my metadata, and most importantly, the "main" directive.
Any idea why? I've used the same approach as backbone itself but that seems to work fine :/
Thanks
Bower gets the list of a package versions from Git tags (they also need to be valid semver).
In the case of backbone.iobind the latest version is 0.4.8.
You can see that when resolving backbone.iobind Bower will checkout the 0.4.8 tag:
bower resolved git://github.com/Soniflow/backbone.iobind.git#0.4.8
However this tag does not contain any bower.json file (unlike the master branch).
The .bower.json file is an internal file used by Bower and should not be confused with bower.json.
I can install Bower and it seems just fine via npm. I create a bower.json file using bower init, and add dependencies. Then when I use bower install, literally nothing happens in the terminal. I can use bower update to install packages, but bower install does not work and I cannot get any error to produce, even with --verbose. I've included bower.json below:
{
"name": "testing",
"version": "0.0.0",
"authors": [
"AJ"
],
"main": "index.html",
"license": "private",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"polymer": "Polymer/polymer#~0.3.0",
"core-menu": "Polymer/core-menu",
"core-ajax": "Polymer/core-ajax"
}
}
edit: using 1.3.3, but I've reproduced this using 1.3.2 as well
Try removing the bower_components directory and running bower install again.
Edit:
This is also related to a circular dependency in Polymer see: https://github.com/bower/bower/issues/1324#issuecomment-44436595
I'm a github enterprise user and I'm using bower to point an internal repository to manage dependencies.
I have set up a repo and included a bower.json file in the root directory. It looks like this:
{
"name": "Axis",
"main": "Axis.js",
"version": "0.0.0",
"authors": [
"Nick Randall"
],
"description": "Chart Axis",
"keywords": [
"d3",
"d3.chart",
"axis"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"d3": "~3.4.6",
"d3.chart": "~0.2.0",
"lodash": "~2.4.1"
}
}
I'm trying to install the repo above as a dependency in a new project using "bower install Org/Axis" and the process hangs after the "Checkout" step. Am I doing something wrong or is this a bug?
My .bowerrc file looks like this:
{
"shorthand-resolver": "https://git.company.com/{{owner}}/{{package}}'.git"
}
and this is the response I get from the command line:
bower Axis#* not-cached https://git.company.com/Org/Axis.git#*
bower Axis#* resolve https://git.company.com/Org/Axis.git#*
bower Axis#* checkout v1.1.1
after that it just hangs there and never progresses.
About a year ago, there was an issue with bower hanging due to problems with the version of unzip. To see if your hanging may have the same cause you might try to install one of the dependencies individually. If an individual install doesn't hang you may have the same issue as before -- it occurred in the presence of certain combinations of node version and bower version. To try and load individually, consider for example:
bower install https://github.com/lodash/lodash.git
It turns out that this was a dumb mistake. I had my .bowerrc in the wrong location. Once I moved it to the root of my project, everything started working. I hope this helps somebody else!