In my node.js (express.js) project, I try to wrap axios to create a HttpClient like this:
import axios from 'axios';
const httpClient = axios.create({ baseURL: 'http://locahost:3003' });
...
export const httpClient = {
...
};
When I run it, I get error SyntaxError: Cannot use import statement outside a module
which complains the line import axios from 'axios'
. How can I get rid of this error? (I come from React-native world, I used the same thing in React-Native, it is fine)