Why bower install polymer with "Polymer/" prefix and version number? - polymer

The Polymer Doc suggests to install polymer with:
bower install --save Polymer/polymer#^1.0.0
Why not just this:
bower install --save polymer

#^1.0.0 instructs Bower to install the latest 1.x.x version of Polymer that doesn't increment the first non-zero leftmost number, so anything between 1.0.0 but below 2.0.0 exclusive (thanks to zerodevx for correction). If you omit that and just run bower install --save Polymer/polymer it will install the latest and greatest version.
The Polymer/polymer command instructs Bower to go to GitHub and install from the source code repository. You could potentially use the shorthand polymer by itself, if the Polymer team has officially registered with Bower (I'm not sure). To be safe, just go directly to the source and install via Polymer/polymer.
I don't think there is a reason to install 1.0.0 specifically. You should install the latest and greatest. So it's just a documentation error. I'll create a pull request to change the documentation.

Just a difference in what gets downloaded. The former, adds an extra folder, "core-component-page". Try it yourself ;-)

The number next to the element is just a version...
If your app works with a specific version you can specified like that

Related

Use an older generator-angular-fullstack version

I want to generate a project with generator-angular-fullstack, but I don't want to use ECMAScript 6. Do you know how I can downgrade the generator? or do you have a better solution for generating a project with angular node and mysql?
Thanks.
A little bit weird that we have to downgrade just to be able to using javascript and CSS by default, not only choose between typescript, babel and various :) Check the current version :
npm list -g generator-angular-fullstack
you will probably see something like
/home/<user>/npm/lib
└── generator-angular-fullstack#3.1.1
Check if you have another local version installed (very likely if you not have been strictly globally from scratch) list without -g :
npm list generator-angular-fullstack
/some/other/dir
└── generator-angular-fullstack#3.3.0
Now, if you have a local version as shown above, uninstall it
npm uninstall generator-angular-fullstack
Finally install the release of generator-angular-fullstack you want. My prefered versions for javascript, HTML, CSS, mongodb, express etc is 2.0.13 and 2.1.1
npm install -g generator-angular-fullstack#2.1.1
check version again to see if you actually have switched releases :
npm list -g generator-angular-fullstack
should now show
/home/<user>/npm/lib
└── generator-angular-fullstack#2.1.1
go to your working directory and run the generator
yo angular-fullstack
..release 2.1.1 is executed. NB: If you now and then see some UNMET PEER DEPENDENCY bower#>=1.0.0 etc, ignore it! It has not so much to do with the generator itself, and everything works fine - so dont worry about that.

Mismatch in gulp local and CLI versions

I had previously installed gulp globally using npm install gulp -g. Then I cloned an existing project, and that required me to use its own gulp. Now when I do a gulp -v from outside my project folder, I get a mismatch like this.
C:\Users\userme>
[11:14:05] CLI version 3.8.11
[11:14:05] Local version 1.0.0
And when I do a gulp from my project folder, I get this.
C:\project\new\tools>
[11:14:26] CLI version 3.8.11
[11:14:26] Local version 3.8.11
Now I have not been able to merge my JS files properly using gulp (I'm getting some weird formatting errors in the min file) and I suspect it has something to do with this mismatch.
Is there a way to remove the global gulp version, but keep the project specific gulp?
Or can I update my global version gulp to #3.8.11?
Note - I did try updating the global gulp by using npm update gulp#3.8.11 -g but nothing happened. i still get the mismatch.
Update to describe the issue:
I am using gulp to merge multiple JS files into 1 single main.js file. The formatting that I get in the merged file has a syntactical error in it.
Expected output in merged file -
...
define('utils/knockoutBindings/slider',['require','ko','jquery'],function(require) {
'use strict';
var ko = require('ko');
var $ = require('jquery');
...
Actual output in merged file (this 1 line of code below is wrongly replacing the entire 4 lines above) -
...
var'utils/knockoutBindings/slider',['require','ko','jquery'],function(require) {
...
It might seem that there is an issue in the gulp code, but the same code is used by other users and it works well on their end. The only difference we have found is in the mismatch in my gulp versions.
I am answering my own question, just so it is useful for others.
Is there a way to remove the global gulp version, but keep the project specific gulp?
No. AFAIK, you are required to install gulp globally as well as one specific to your project.
More info on gulp versions here.
Why do we need to install gulp globally and locally?
http://blog.dwaynecrooks.com/post/110903139442/why-do-we-need-to-install-gulp-globally-and
https://github.com/gulpjs/gulp/issues/171
https://github.com/gulpjs/gulp/issues/140
Or can I update my global version gulp to #3.8.11?
Since I was facing a mismatch in my local version, I had to update it from the project folder itself.
npm install gulp#3.8.11 --save
More info on this here.
http://www.eskocruz.com/gulp-version-mismatch
To update your Local version npm install gulp#version_you_need
To update CLI version npm install -g gulp#version_you_need
Removing node_modules folder and running npm install gulp within that dir sorted my issue out.
npm install -g gulp wasn't fixing it for me, from either in or out of the project folder. My gulp version was already correct in my package.json file. All I had to do was run npm install from within the project folder, and the gulp version from in the project folder was corrected.
Updating both the local version same as that of the global version fixed the issue. My initial gulp -v yielded CLI version 3.9.1 and Local version 4.0.0. I updated the local version from within the project folder npm install gulp#3.9.1 --save. This resolved my issue .
Gulp 4 uses an updated CLI which needs to be updated globally. This CLI is backwards compatible with any Gulp 3.X projects you may have locally - Read more.
It seems that the latest version (at the time of this post) of gulp-cli is 2.3.0 which means there will always be a mismatch.
If you run npm install -g gulp, then the latest version of the CLI will be installed. If you have any other version installed then it will update to the latest version.
The local version's latest release (at the time of this post) is 4.0.2.
Run npm install --save-dev gulp to install the latest version of Gulp in your project folder as a dev-dependency. Like with the CLI version it will update if you have an older version.
Mismatched versions work like normal.
SIDE NOTE: Remember to prefix global installs with sudo if you're working on a Mac and you have admin rights e.g. sudo npm install -g gulp.
BUT if you don't have admin rights and you can update the local version, but not the global version, then you can run node ./node_modules/gulp/bin/gulp.js from your project folder and it will execute the gulp file, even if you have the wrong CLI version, but you need to have the default task set up.

How run Polymer code example?

I have downloaded this example : PolymerElements/app-layout-templates
..and I can't make it work (whereas I was able to access this one : PolymerElements/polymer-starter-kit)
I ran the following lines in the terminal :
bower init
bower -save polymer
bower bower install –save Polymer/polymer-elements Polymer/polymer-ui-elements
bower update
...and then accessed the folder via a python server.
Do you have some tips to make it work ?
If you want to try out PolymerElements/app-layout-templates then that's what you need to install on bower. Bower will download all the required dependencies for app-layout-templates to work.
bower install --save PolymerElements/app-layout-templates
After this you can start python server on folders app-layout-template, app-layout-template/nav-view etc to see how it works.
Also the repositories Polymer/polymer-elements, Polymer/polymer-ui-elements are invalid. The polymer elements are available in github repository https://github.com/PolymerElements. So to download polymer elements try something like below
bower install --save PolymerElements/iron-elements
bower install --save PolymerElements/paper-elements
bower install --save PolymerElements/neon-elements
bower install --save PolymerElements/platinum-elements

Is there any way to automatic change package.json's latest or asterisk(*) mark to specific version?

I use npm Node Packaged Modules to manage project library,
But I notice unconditional latest update version make me hell.
(Too many unmet dependencies error..)
So I try to find to change all latest version to my local current version. I find the --save flag make some libraries specific version, but not all. Is there any good way to solve this problem?
As per the NPM documentation, you can use a "semver" string to specify how to match the specific version, or how that version number can change, to control your dependencies as follows:
version Must match version exactly
>version Must be greater than version
>=version etc
<version
<=version
~version "Approximately equivalent to version" See semver(7)
^version "Compatible with version" See semver(7)
1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0
It's also worth reading the node-semver documentation which defines in more detail how to specify and control the versions of your dependencies that match.
The other command to investigate is npm shrinkwrap - this prepares a npm-shrinkwrap.json file (which will be used by npm install instead of package.json, if present) which has the specific versions recorded in it, meaning future npm install's should always give those specific versions. See the NPM documentation for shrinkwrap for further information.

error when installing polymer designer on local machine

I have cloned the git for polymer designer on my mac. Following the getting started instructions for Polymer designer works fine until I run bower install
-bash: bower: command not found
Also index.html cannot be loaded by the local httpserver.
I see this is a standard error but several solutions on stack. I need to setup this tool locally to add a custom library.
You nee to install bower: http://bower.io/#install-bower
npm install -g bower
Try this: bower install --save Polymer/polymer