title: Compiling and initializing external JS library in Laravel mix
body: <p>I am using Laravel mix to compile all my assets, but I'm having trouble initializing an external library. </p>
  
  <p>I have used <code>npm install aos --save</code> to get the dependency, and within my <code>app.js</code> I am calling it like this:</p>
  
  <pre><code>require('aos/dist/aos');
  AOS.init();
  </code></pre>
  
  <p>My mix file:</p>
  
  <pre><code>mix
      .js('resources/js/app.js', 'public/js')
      .js('resources/js/index.js', 'public/js')
      .sass('resources/sass/app.scss', 'public/css')
      .sass('resources/sass/index.scss', 'public/css');
  </code></pre>
  
  <p>Now inside a view I am including the file in <code>head</code>:</p>
  
  <pre><code>&lt;script defer src="{{ mix('js/app.js') }}"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But I keep getting in my view that </p>
  
  <pre><code>Uncaught ReferenceError: AOS is not defined
  </code></pre>
  
  <p>How can I resolve it? If it is being referenced within same file and after the library requiring, why is it not working? </p>