Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

qbixx's avatar
Level 4

Import Axios results in Uncaught SyntaxError: Invalid regular expression flags

I'm currently building a website where i'm using Laravel Mix to compile all my assets through Webpack.

It's not a Laravel project, but i've pulled in Laravel Mix through Yarn. Everything is working fine untill i'm trying to include Axios into my build.

I've added Axios with:

yarn add axios --dev

First, i've use the extract method in Laravel Mix:

mix.extract(['axios', 'vue', 'jquery']);

Second, i've tried to import Axios directly into my main.js file

import Axios from 'axios';

However, both options are giving exactly the same error: Uncaught SyntaxError: Invalid regular expression flags. The error is coming from the line below in het compiled js file:

return Promise.reject(reason)})}}),(function(module,exports,__webpack_require__){"use strict";var utils=__webpack_require__(0);module.exports=function transformData(data,headers,fns){utils.forEach(fns,function transform(fn){data=fn(data,headers)});return data}}),(function(module,exports,__webpack_require__){"use strict";module.exports=function isAbsoluteURL(url){return/^([a-z][a-z\d\+\-\.]*:)?\/\}}),(function(module,exports,__webpack_require__){"use strict";module.exports=function combineURLs(baseURL,relativeURL){return relativeURL?baseURL.replace(/\/+$/,'')+'/'+relativeURL.replace(/^\/+/,''):baseURL}}),(function(module,exports,__webpack_require__){"use strict";var Cancel=__webpack_require__(11);function CancelToken(executor){if(typeof executor!=='function'){throw new TypeError('executor must be a function.')}

The error starts at the forward slash in isAbsoluteURL(url){return/.

Why is this error showing up? And how can I resolve this?

0 likes
0 replies

Please or to participate in this conversation.