npm install axios. Now what?

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

I've found a few pages on how to use npm packages in Laravel, but nothing that describes how to use a js library.

jimmcm88 replied 1 year ago

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.


Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us