'X Is not a function' in CommonJS


I’ve got the following code I transformed from a Trypescript, ESM-syntax based file to a Javascript, CJS-syntax file.

const apiClientFactory = require("@vue-storefront/core");

function onCreate(settings) {
  return {
    config: settings,
    client: {},

const getPrice = () => {

const { createApiClient } = apiClientFactory({
  api: {

module.exports = {

I can not seem to find if the error "apiClientFactory is not a function" originates from old ESM-based code. Or that the function isn’t called properly. However, apiClientFactory is correctly imported (ESM syntax)


What are you trying to achieve with this?

Because the whole Vue Storefront project uses TypeScript, so I recommend you to use it and follow the procedures and code standards that we are using.

To find a good example on the API please check the code for the integrations of Magento or Vendure.

Also, I want to invite you to our Discord server at https://discord.gg/vuestorefront

Answered By – Heitor

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.