Search code examples
javascripttypescriptpolymerpolymer-3.x

How to import <paper-textarea> for Polymer 3.x?


I tried the following terminal command:

npm install --save paper-input

then got the following error:

enter image description here

A key statement in that error message is

npm WARN paper-input@3.0.2 requires a peer of react@>= 15.0.0 but none is installed. You must install peer dependencies yourself.

Also, it seems to deposit the repo in

node_modules > paper-input (like a 2.x element)

instead of:

node_modules > @polymer > paper-input (like a 3.x element should)

What's going on here? All I want to do is install paper-input.


Solution

  • Will the following work?

    npm install --save paper-input
    

    No, that paper-input package is actually for React. The Polymer package is @polymer/paper-input, so you would run:

    npm install --save @polymer/paper-input
    

    And your import usage is indeed correct (see demo).

    I don't see a v3 element for paper-input

    I assume you were looking at the paper-input's GitHub releases, which does not include any versions newer than v2.2.3. However, there are in fact newer versions in NPM, but they're not tagged in GitHub for some reason. The element version compatible with Polymer 3.x is 3.0.0-pre.21.