Why is bower not using my bower.json resolutions? - angularjs

I have a project I need to use angularjs 1.2 with. I have a bower.json file with the following:
{
"name": "myproject",
"dependencies": {
"angular": "1.2.32"
},
"resolutions": {
"angular": "1.2.32"
}
}
When I install angular it asks me which version I want, although it should not if I understood correctly. And when I try to install another project like angular-route it asks again and even installs the wrong one:
bower install angular-route
bower angular-route#* cached https://github.com/angular/bower-angular-route.git#1.6.4
bower angular-route#* validate 1.6.4 against https://github.com/angular/bower-angular-route.git#*
bower angular#1.6.4 cached https://github.com/angular/bower-angular.git#1.6.4
bower angular#1.6.4 validate 1.6.4 against https://github.com/angular/bower-angular.git#1.6.4
Unable to find a suitable version for angular, please choose one by typing one of the numbers below:
1) angular#1.2.32 which resolved to 1.2.32 and is required by angamcharts2
2) angular#1.6.4 which resolved to 1.6.4 and is required by angular-route#1.6.4
Prefix the choice with ! to persist it to bower.json
? Answer !1
bower angular resolution Saved angular#1.2.32 as resolution
bower angular-route#^1.6.4 install angular-route#1.6.4
angular-route#1.6.4 bower_components/angular-route
└── angular#1.2.32
I know there is angular-route 1.2.32 but I don't want to install all my packages by hand with the correct version. Why is the "resolutions" not working?

Related

angularjs: can't install angular-cookies to my project

I my project I came into an issue about the package of angular-cookies.
I have download the package and place it in my project. And as usually, in index.html, I add a script tag:
<script src="vendor/angular-cookies/angular-cookies.min.js" charset="UTF-8"></script>
But when the pages loaded I got an error message:
Uncaught TypeError: c.module(...).info is not a function at angular-cookies.min.js:7
in the package, it uses angular.module.info but it is not regarded as a function?
So what is the reason for this issue? Is it because version issue? Any help
I had the same problem with a recent bower update I've done. I don't know if the angular 1.6.3 is stable so I went to https://code.angularjs.org/latest/ and I saw that is 1.5.8 angular version which is used.
So to resolve it, I added these versions in my bower.json :
"dependencies": {
"angular-cookies": "1.5.8",
},
"resolutions": {
"angular": "1.5.8"
}
You should install particular dependecies according to angular.You can achieve it by using bower install like this:
bower install angular-cookies#1.5.8
bower install angular#1.5.7

typings.json not getting updated typings install --ambient

I used to work with tsd for managing my type definitions, but as it's deprecated, I'm trying to migrate to typings which is my opinion more complicated, but should be the way to go, I guess.
I want to install a type definition and for that I use the --ambient flag.
In Visual Studio I have the typings.json file which looks like that:
{
"name": "Test",
"version": false,
"ambientDependencies": {
"angular": "github:DefinitelyTyped/DefinitelyTyped/angularjs/angular.d.ts#ca92a5b250433c38230b5f4138b36453862342bf",
"jquery": "github:DefinitelyTyped/DefinitelyTyped/jquery/jquery.d.ts#ca92a5b250433c38230b5f4138b36453862342bf"
}
}
This was automatically created when migrating from tsd to typings but now once I need a new type definition, for instance angular-route I use the following command:
typings install angular-route --ambient
This works fine, but the typings.json does not get updated.
What is the point and why am I missing? Why were angular and jquery both migrated to typings.json and when installing angular-routethe file does not get refreshed?
Actually in Typings 1.0 they did some breaking changes.
"ambient" is now "global". Just in case, installing from DefinitelyTyped must be explicit.
The following will install jQuery and save it to typings.json
typings install dt~jquery --global --save
See the link in Igor's answer for more info
You forgot --save
typings install angular-route --ambient --save
command syntax above is now obsolete and only applicable to version 0.x
Link to Typings command help
Update
As pointed out by #AndresM there are breaking changes in going from version 0.x to 1.x. See the documentation Updating From 0.x to 1.0?. The command syntax in #AndresM answer is the correct way to execute a typings command using DefinitelyTyped store and Typings version 1.x.
Now with Typescript2.0(https://blogs.msdn.microsoft.com/typescript/2016/09/22/announcing-typescript-2-0/) the global is also gone. The following will install jQuery and angular typings:
npm install --save #types/angular #types/jquery
Your package.json will then have:
"dependencies": {
"#types/angular": "^1.5.16",
"#types/jquery": "^2.0.33"
}
Your node_modules directory will have #types/angular and #types/jquery directories which contain index.d.ts files.

Add Angular-ui through bower

I'd like to use the angular-ui filters package and I'd like to install it through bower. I've run bower install --save angular-ui which installs it and inserts it into the bower.json file.
Unfortunately it doesn't seem to actually import the files into the project. I've already got ui.bootstrap in there, I can't find any instructions to install the filters part.
I've seen issues where the folder already exists in bower_components and so bower assumes that its already there and doesn't add the files.
bower uninstall angular-ui
check that the angular-ui folder isn't in bower-components and if it is then delete it.
bower install angular-ui --save

Bower install unstable release (1.4.0-rc.0) of angular

Having trouble installing angular#1.4.0-rc.0 via bower - when I run:
bower install --save angular#1.4.0-rc.0
I get the error
no matches found: angular#1.4.0-rc.0
However running bower update angular shows packages that depend on 1.4.0-rc.0:
angular-cookies#1.4.0-rc.0 depends on angular#1.4.0-rc.0 which resolved to angular#1.4.0-rc.0
Adding "angular": "~1.4.0-rc.0" or "angular": "1.4.0-rc.0" doesn't help either!
Thanks guys!
delete your previous bower_components folder or your custom location.
Thanks to #nitin, deleting my bower_components folder and reinstalling did the trick.

Bower install anuglar-module is installs angular instead?

I am trying to install this angular module (angular-stripe). When I type bower install angular-stripe (as the docs recommend) I get:
bower angular-stripe#* cached git://github.com/bendrucker/angular-stripe.git#4.1.0
bower angular-stripe#* validate 4.1.0 against git://github.com/bendrucker/angular-stripe.git#*
bower angular-cookies#~1.3.11 cached git://github.com/angular/bower-angular-cookies.git#1.3.12
bower angular-cookies#~1.3.11 validate 1.3.12 against git://github.com/angular/bower-angular-cookies.git#~1.3.11
bower angular#1.3.12 cached git://github.com/angular/bower-angular.git#1.3.12
bower angular#1.3.12 validate 1.3.12 against git://github.com/angular/bower-angular.git#1.3.12
Unable to find a suitable version for angular, please choose one:
1) angular#1.3.11 which resolved to 1.3.11 and is required by angular-animate#1.3.11, angular-cookies#1.3.11, angular-mocks#1.3.11, angular-resource#1.3.11, angular-route#1.3.11, angular-sanitize#1.3.11, angular-scenario#1.3.11, angular-touch#1.3.11, nightwalker
2) angular#~1.3.2 which resolved to 1.3.11 and is required by angular-stripe#4.1.0
3) angular#1.3.12 which resolved to 1.3.12 and is required by angular-cookies#1.3.12Prefix the choice with ! to persist it to bower.json
This looks like I am installing angular all over again or something. Is there a way to avoid this?
You need to add the resolution
"resolutions": {
"angular": "~1.3.x"
}
In your bower.json file

Resources