Also by changing the import statement from this:
import axios from 'axios';
to this: (importing the module package directly in the file where axios is used)
import axios from 'axios/dist/browser/axios.cjs';
resolved the error.