Adding JS libraries in Laravel

by John H
~1 minute

Adding a library in Laravel

To add with npm the library needs to be included and compiled with Webpack

 

Here is an example with Moment.js

get the package (this will put in a dependency in package.json) npm install moment

install npm install

call it in the laravel mix /resources/js/app.js moment = require('moment');

compile it for the env npm run dev or npm run production

 

More info about mix

https://laravel.com/docs/5.8/mix