title: Cropper.js - The first argument is required and must be an <img> or <canvas> element
body: <p>I'm totally new to JS and I'm trying to use <a href="https://github.com/fengyuanchen/cropperjs" rel="nofollow noreferrer">Cropper.js</a>. I couldn't run the given example on README either. This is the code that I'm trying to run:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//import Cropper from 'cropperjs';
  
  let image = document.getElementById('img');
  const cropper = new Cropper(image, {
    aspectRatio: 16 / 9,
    crop(event) {
      console.log(event.detail.x);
      console.log(event.detail.y);
      console.log(event.detail.width);
      console.log(event.detail.height);
      console.log(event.detail.rotate);
      console.log(event.detail.scaleX);
      console.log(event.detail.scaleY);
    },
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>img {
  
      display: block;
      max-width: 100%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Cropper Test&lt;/title&gt;
          &lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.css"/&gt;
          &lt;link rel="stylesheet" href="style.css"/&gt;
          &lt;script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.6/cropper.js"&gt;&lt;/script&gt;
          &lt;script type="text/javascript" src="test.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div&gt;
              &lt;img id="img" src="test.png"/&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>If I uncomment the import statement, in console it shows : Cannot use import statement outside a module.
  I did search here for this problem but couldn't find anything that fixes my problem.</p>