I'm still new to npm, but I'd like to make use of the axios library. So I ran npm install axios
, but how do I now reference it in Laravel 5.4? There's no axios.min.js
file in either resources/assets/js
nor public/js
.
Maybe webmix needs to be configured? But how,...I mean,..I see the source file in node_modules/axios/dist/axios.min.js
, but do I copy that file over to public/js
? In that case, why did I bother with npm install
, where I could've simply downloaded it from https://github.com/mzabriskie/axios/tree/master/dist.
I've found a few pages on how to use npm packages in Laravel, but nothing that describes how to use a js library.
Hi Sanuglia,
You can import axios in your bootstrap.js file using
import axios from 'axios';
then bind it to the window so you can use it throughout your application:
window.axios = axios;
Hope this helps.
Jim
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community