bower: no suitable angular version - bower

Maybe I don't understand SemVer syntax or maybe I don't understand bower (I have version 1.4.1), but I have an app whose bower.json is:
{
"name": "MyApp",
"description": "My AngularJS Project....",
"version": "0.0.0",
"homepage": "https://github.com/angular/angular-seed",
"license": "MIT",
"private": true,
"dependencies": {
"angular": "1.3.x",
"angular-route": "1.3.x",
"angular-loader": "1.3.x",
"angular-mocks": "~1.3.x",
"angular-ui-grid": "~3.0.0-rc.20",
"angular-spinkit": "~0.3.3",
"angular-bootstrap": "0.13.0",
"bootstrap": "3.3.4",
"angular-animate": "~1.3.x",
"file-saver.js": "~1.20150507.2"
},
"resolutions": {
}
}**
When I do a 'bower update', it is “unable to find a suitable version for angular”, but I don't understand why not. Here's the output (#1 seems to be the problem):
Unable to find a suitable version for angular, please choose one:
1) angular#>=1.2.16 <=1.3.x which resolved to 1.2.28 and is required by angular-ui-grid#3.0.0-rc.22
2) angular#1.3.16 which resolved to 1.3.16 and is required by angular-animate#1.3.16, angular-loader#1.3.16, angular-mocks#1.3.16, angular-route#1.3.16
3) angular#1.3.x which resolved to 1.3.16 and is required by MyApp
4) angular#>=1.3.0 which resolved to 1.3.16 and is required by angular-bootstrap#0.13.0
5) angular#* which resolved to 1.3.16 and is required by angular-spinkit#0.3.3
So my reading of that output is that all packages would be happy with version 1.3.16 of angular, except for angular-ui-grid (“resolved to 1.2.28”) But why? Isn't 1.3.16 >=1.2.16 <=1.3.x ? And so isn't version 1.3.16 of Angular a suitable version? isn't it the ONLY suitable version? or maybe I'm misunderstanding what bower is trying to tell me.
I do understand that I can select one of the choices and even add a '!' to persist my choice, but I don't understand why a choice is needed.
Thanks

c0bra - thanks for setting up that plunker - it helped me to easily verify what I believe I finally (after lots of digging) determined is the problem:
there seems to be a bug in older versions of semver.js - I traced down, down, down into the code and the <=1.3.x gets morphed into <=1.3.0-0, and that means that 1.3.16 fails that test.
But that bug has been fixed in the NPM-delivered semver module - I was able to use your plunker to demonstrate to myself that 1.3.16 passes the test with 'latest' semver code, just as you set it up, but fails when I switch to older versions of semver (e.g. "^2.3.0", which seems to be what the bower package requires in its packages.json).
But even the latest bower on github seems to have that ^2.3.0 dependency for semver. So I'll see if I can submit a request to whoever maintains bower to get that upgraded. But I do not see much activity on bower/github of late.
In the meantime, I guess I'm stuck with being forced to answer the question above, since I'm using NPM to get bower, I don't think I can easily override it's semver dependency.

Related

Twilio 'Header' import issue

When i installed latest twilio's version which is "twilio": "^4.7.2", and building the project (npm run build) the following error occurs,
node_modules/twilio/lib/base/BaseTwilio.d.ts:22:19 - error TS2304: Cannot find name 'Headers'.
22 headers?: Headers;
~~~~~~~
Found 1 error in node_modules/twilio/lib/base/BaseTwilio.d.ts:22
My node version : v16.18.1
Npm version : v8.19.2
I got the same issue once I installed the twilio npm package of the exact same version ^4.7.2. I'm assuming it's some typescript compilation issue. And there is a trick that you can use to make it work.
Add this in your tsconfig.json:
{
"compilerOptions": {
"skipLibCheck": true,
}
}
This will solve your issue, but don't consider it as a fix. It's rather workaround.
P.S. This will also speed up your overall typescript compilation process.

Unable to find suitable version for underscore

I get the following error:
Message:
Unable to find suitable version for underscore
Details:
code: ECONFLICT
picks: [object Object],[object Object],[object Object]
With the following bower file, this error I have never come across before. I cannot use the interactive shell, as this gets deployed to continuous integration. We also prefer to use Github repo links (don't ask me why) over bower packages.
{
"name": "Nightbird",
"version": "0.0.1",
"main": "src/css/style.scss",
"dependencies": {
"backbone": "git#github.com:jashkenas/backbone.git#1.1.2",
"underscore": "git#github.com:jashkenas/underscore.git#1.6.0",
"aisis-bootstrap-theme": "git#github.com:AdamKyle/Aisis-Bootstrap-Theme.git#0.5.0",
"selectize.js": "git#github.com:brianreavis/selectize.js.git#0.8",
"underscore.string": "git#github.com:epeli/underscore.string.git#v2.3.2",
"jquery-bootpag": "git#github.com:botmonster/jquery-bootpag.git#1.0.5",
"underscore.inflection": "git#github.com:jeremyruppel/underscore.inflection.git",
"moment": "git#github.com:moment/moment.git",
"bootstrap-markdown": "git#github.com:toopay/bootstrap-markdown.git#2.5.0",
"markdown-js": "git#github.com:evilstreak/markdown-js.git#v0.5.0",
"to-markdown": "git#github.com:domchristie/to-markdown.git#v0.0.2",
"font-awesome": "git#github.com:FortAwesome/Font-Awesome.git#4.2.0",
"react-bower": "git#github.com:reactjs/react-bower.git#0.11.1",
"showdown": "git#github.com:coreyti/showdown.git#0.3.1",
"pure": "git#github.com:yahoo/pure.git#0.5.0"
}
}
Any idea whats going on? Is this a bug? or just a developer being dumb?
You have a conflict between 3 different versions of underscore.
The reason for this is that underscore is required by 3 of your dependencies: Nightbird, backbone and underscore.inflection.
Using the latest version of Bower you can see the following information:
Unable to find a suitable version for underscore, please choose one:
1) underscore#1.6.0 which resolved to 1.6.0 and is required by Nightbird
2) underscore#>=1.5.0 which resolved to 1.6.0 and is required by backbone#1.1.2
3) underscore#~1.7.0 which resolved to 1.7.0 and is required by underscore.inflection#1.2.0
You can force bower to use a specific version in case of resolution by adding the following to your bower.json. In this example it will force using 1.6.0:
"resolutions": {
"underscore": "1.6.0"
}

installing modules from git zendframework 2

Is there any way to install modules by directly downloading from git-hub without php composer.phar. Because my php composer is not working.
this is the error
$ php composer.phar require webino/webino-image-thumb:2.*
./composer.json has been updated
Loading composer repositories with package information
Ignoring unknown parameter "server role"
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Can only install one of: zf-commons/zfc-admin[v0.1.0, dev-master].
- Can only install one of: zf-commons/zfc-admin[v0.1.0, dev-master].
- Installation request for zf-commons/zfc-admin 0.1.0 -> satisfiable by zf-commons/zfc-admin[v0.1.0].
- Installation request for zf-commons/zfc-admin == 9999999-dev -> satisfiable by zf-commons/zfc-admin[dev-master].
Installation failed, reverting ./composer.json to its original content.
My composer.json looks like this:
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [ "framework", "zf2" ],
"minimum-stability": "dev",
"homepage": "framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.2.0",
"webino/webino-image-thumb": "1.*",
"zf-commons/zfc-admin":"0.1.0"
}
}
There are three ways you can typically install Zend 2 Modules.
Through the file system
Git
Composer
You could just run:
https://github.com/ZF-Commons/ZfcAdmin.git
to get the module. But I am unsure if it is going to work since you likely have a dependency issue that needs resolving. I would recommend sticking with composer. Please post your whole composer.json file and I'm sure that the issue can be solved.
I cannot reproduce your error.
I copy your composer.json file into an empty directory and execute composer install there. Works.
I then issue composer require webino/webino-image-thumb:2.*, and it downloads that version (2.0.0-RC1) just fine.

Bower installation directory changes: sometimes the version is appended

I have a project that uses bower.
My bower.json:
{
"name": "myproject",
"version": "0.0.0",
"dependencies": {
...
"angular-sanitize": "1.2.1",
...
Then I run bower install.
Then I can see what's installed:
➜ myproject git:(develop) ✗ ls app/bower_components/angular-sanitize/
README.md angular-sanitize.min.js bower.json
angular-sanitize.js angular-sanitize.min.js.map
But then a coworker checkouts the project, he bower installs, on his machine, this dependency is installed in
app/bower_components/angular-sanitize/bower-angular-sanitize-v1.2.1/
instead of my original
app/bower_components/angular-sanitize/.
So why does bower sometimes adds bower-angular-sanitize-v1.2.1/ to the installation folder ?
Notes: We have the same bower.json and version of bower. If I delete my bower_dependencies and reinstall, I still have the old folder.
Edit:
What I understand (after playing a while with bower install a removing bower_components, clearing bower cache etc)...
My problem is linked to how bower resolves resolutions. It seems that versions are resolved once bower prompts you with a choice for choosing a few version (jquery, angular and bootstrap).
But still, a few things that I don't understand:
On my machine, even after removing bower cache, removing bower_dependencies or copying the bower.json in a new folder, bower never prompts me about resolutions after a "bower install" (so how are they stored?)
On my coworker machine, bower prompts for resolutions only on his native system (and not when "bower install"ing in a vagrant machine).
So, I have a few more obscure points:
How does bower store the dependencies resolutions ? Is there documentation about this anywhere ? The only place I have found something is on some github issues (and by playing around with it).
My bower.json:
{
"name": "myproject",
"version": "0.0.0",
"dependencies": {
"json3": "~3.2.4",
"bootstrap-sass": "~2.3.1",
"es5-shim": "~2.0.8",
"angular-cookies": "~1.2.1",
"angular-dragdrop": "<=1.0.4",
"angular-strap": "~0.7.1",
"angulartics": "~0.8.4",
"jquery": "~1.8.3",
"underscore": "~1.4.4",
"angular": "1.2.1",
"angular-route": "1.2.1",
"angular-resource": "1.2.1",
"angular-sanitize": "1.2.1",
"angular-ui-date": "~0.0.3",
"jquery.masonry": "v2.1.08",
"bootstrap": "~2.3.1",
"angular-bootstrap": "~0.10.0",
"highcharts": "~3.0.2",
"jqueryui-timepicker-addon": "~1.4",
"moment": "~2.0.0",
"bootstrap-notify": "0.1.0",
"mjaalnir-bootstrap-colorpicker": "~1.0.0"
},
"devDependencies": {
"angular-mocks": "~1.0.7",
"angular-scenario": "~1.0.7"
},
"resolutions": {
"jquery": "~1.8.3",
"angular": "1.2.1",
"bootstrap": "~2.3.1"
}
}
We have the same problem here - it seems when the resolutions are defined within bower.json on install with empty cache and an empty bower_components directory, the package gets installed into bower_components/package/package-version whereas if you select the resolutions interactively during install, then it gets installed into bower_components/package - so if you hit that problem, clean the cache (e.g. bower cache clean), delete installed components (e.g. rm -rf bower_components/) and remove the resolutions from bower.json and then bower install.
I had the same issue. I had to go trough every dependency and install it separately, check its version and then resolving it's resolution when asked. Once it worked and didn't put the folder with the package version number, then I saved the bower.json with the right version and with the resolution (again, when asked to). It worked for me, now all bower dependencies are versioned, no "*" or "latest", and some even without the "~" at the beginning of the version.
Hope this helps you and everyone facing this problem.

Installing suggested composer packages ZF2 (Zend Framework 2)

when you use the zend skeleton to start your new project and composer to install packages it recommends this:
"doctrine/common": "Doctrine\\Common >=2.1 for annotation features",
"ext-intl": "ext/intl for i18n features",
"pecl-weakref": "Implementation of weak references for Zend\\Stdlib\\CallbackHandler",
"zendframework/zendpdf": "ZendPdf for creating PDF representations of barcodes",
"zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha for rendering ReCaptchas in Zend\\Captcha and/or Zend\\Form"
I could install the zendpdf, zendservice-recaptcha and doctine/common package but not the PECL ones.
I think it's a little sad that zf2 suggest the packages, but leaves users alone with, how to properly configure the composer.json.
I heard composer could also get PECL packages, but couldn't find any documentation on it.
How do I install them?
To install the suggested packages, modify composer.json to include them.
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*",
"doctrine/common": "dev-master",
"zendframework/zendpdf": "2.*",
"zendframework/zendservice-recaptcha": "2.*"
}
Then run
php composer.phar update
Note: that composer installs doctrine/common by using
git clone http://github.com/doctrine/common
On Windows git needs to be in your PATH environment variable.
Regarding ext/intl, this extension is bundled with PHP as of PHP version 5.3.0. and can be found in the ext/ folder of your php installation.[1]
To enable, uncomment (remove the semi-colon before the directive) it in php.ini
extension=php_intl.dll
Regarding pecl-weakref, this is also a PHP extension however this is not bundled with php and needs to be installed. More information on how to do that can be found at http://php.net/manual/en/install.pecl.php
A DLL for this PECL extension is currently unavailable. See also the
building on Windows section. [4]
[1] http://php.net/manual/en/intl.requirements.php
[2] http://php.net/manual/en/weakref.installation.php
[3] http://php.net/manual/en/install.pecl.intro.php
[4] http://php.net/manual/en/install.pecl.windows.php

Resources