-1

I wanted use a jquery function that uses an external library inside my component so Ive added its library in angular.json

            "scripts": [
              "node_modules/jquery/dist/jquery.min.js",
              "node_modules/popper.js/dist/umd/popper.min.js",
              "node_modules/bootstrap/dist/js/bootstrap.min.js",
              "src/html5media.min.js",
              "src/plyr.min.js",
            ]

otherwise i even used this libraries as main index.html file

    <link rel="stylesheet" href="https://cdn.plyr.io/3.5.6/plyr.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/html5media/1.1.8/html5media.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/plyr/3.5.6/plyr.min.js"></script>
  </head>

then imported jquery function in my component

import * as $ from 'plyr';

as you can see on below link, this jquery function uses a class (Plyr) that should be refer to library link but when i serve my projects, see this error:

error TS2304: Cannot find name 'jQuery'.

37         jQuery(function ($) {
           ~~~~~~

and an interesting, when i resave save component file, it works but inside terminal the error remains:

error TS2304: Cannot find name 'Plyr'.

35                 var player = new Plyr('#audio1', {
                                    ~~~~

the mentioned jquery file:

0

1 Answer 1

0

If you want to import plyr, install it using

npm i plyr

and then you can import it in your component using

import Plyr from 'plyr';.

Sign up to request clarification or add additional context in comments.

1 Comment

i did it before and gave this error as well error TS2304: Cannot find name 'jQuery' Cannot find name 'Plyr'.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.