Support the ongoing development of Laravel.io →
Installation Configuration

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.

Last updated 3 years ago.
0

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

Last updated 8 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Sanuglia sanuglia Joined 11 May 2017

Moderators

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

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.