Can I install Polymer (1.0) with NPM?

Zach Lysobey picture Zach Lysobey · Jun 30, 2015 · Viewed 8.4k times · Source

I'm trying to use Polymer on a new project, and was trying to avoid using Bower in favor of NPM for front-end dependency management.

The getting started page gives instructions for using Bower (and using a .zip file, etc...) but no mention of NPM.

I have used NPM by pointing directly at a GitHub repo before, but I cannot seem to get this to work for Polymer.

When I run this:

npm install [email protected]:Polymer/polymer.git#v1.0.5

I get this error:

npm ERR! notarget No compatible version found: git@'github.com:Polymer/polymer.git'

npm ERR! notarget Valid install targets:

npm ERR! notarget ["0.1.0","0.1.1","0.1.2","0.1.3","0.1.4","0.1.5"]

Is there something I'm missing, or do I need to bite the bullet and use Bower?

Answer

Kiara Grouwstra picture Kiara Grouwstra · Mar 17, 2016

Since the earlier answers, Polymer has now indeed become available on NPM. To install it:

npm i Polymer

Note that it doesn't include the standard elements collection; those can be found here:

npm i npm-polymer-elements

You can then include them in your HTML:

<!-- for custom elements -->
<link rel="import" href="/node_modules/@polymer/polymer/polymer.html"/>
<!-- for standard elements -->
<link rel="import" href="/node_modules/paper-button/paper-button.html"/>
<paper-button>click</paper-button>

Unfortunately loading Polymer through webpack currently doesn't seem possible yet, meaning if your node_modules (or bower_components) folder isn't in a publicly accessible location, you may want to make a Grunt/Gulp task to copy it over for after future updates...