I am using Laravel mix to compile all my assets, but I'm having trouble initializing an external library.
I have used npm install aos --save to get the dependency, and within my app.js I am calling it like this:
require('aos/dist/aos');
AOS.init();
My mix file:
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');
Now inside a view I am including the file in head:
<script defer src="{{ mix('js/app.js') }}"></script>
But I keep getting in my view that
Uncaught ReferenceError: AOS is not defined
How can I resolve it? If it is being referenced within same file and after the library requiring, why is it not working?
import AOS from 'aos'; AOS.init()orvar AOS = require('aos'); AOS.init();