Velo ModuleLoadError: Cannot find module 'wix-ecom-backend/v1' despite Wix Stores being installed

Hello everyone,

I’m trying to create a dynamic product in my Wix Store and add it to the cart using Velo backend code. I’ve followed the official documentation, but I’m consistently running into a ModuleLoadError.

My site has the Wix Stores app installed and published.

Here is the backend code (backend/pay-service.jsw) that is causing the issue:

JavaScript

import wixStores from 'wix-stores-backend';
import { cart } from 'wix-ecom-backend/v1';

export async function addDynamicItemToCart(lessonId, languageId, teacherId, selectedSlotValues, numberOfWeeks) {
    // ... logic to prepare product data ...
    const newProduct = {
        // ... product properties ...
    };

    try {
        const createdProduct = await wixStores.createProduct(newProduct);
        const itemToAdd = {
            productId: createdProduct._id,
            quantity: 1,
        };

        const addedItem = await cart.addProducts([itemToAdd]);
        return { success: true, cartId: addedItem.id };
    } catch (error) {
        return { success: false, error: error.message };
    }
}

When I run this code, I get the following detailed error log:

ModuleLoadError: Error loading web module backend/pay-service.jsw: Both resolutions failed at _load!
...
Original resolver: Cannot find module 'wix-ecom-backend/v1'
...
YarnPNP: Your application tried to access wix-ecom-backend, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Troubleshooting Steps I’ve Already Taken:

  • Confirmed that the Wix Stores app is installed and active on my site.

  • The import statement import { cart } from 'wix-ecom-backend/v1'; is exactly as specified in the Wix Velo documentation.

  • I have saved and published the site multiple times.

  • I have checked for any missing npm packages, but wix-ecom-backend is a built-in module, not a separate package.

The error message Your application tried to access wix-ecom-backend, but it isn't declared in your dependencies suggests a server-side issue where the module is not being correctly provisioned for my project, despite the required app being installed.

Has anyone else encountered this specific YarnPNP error with wix-ecom-backend/v1? Any guidance on how to resolve this platform-level issue would be greatly appreciated.

Thank you!

Hi, @Elif_Altun !!

Wouldn’t it work if you rewrote it like this? :raising_hands:

import { cart } from 'wix-ecom-backend/v1';

to

import { cart } from "wix-ecom-backend";

Can you share the documentation where it’s referenced like this? As far as I can tell it should be import { cart } from "wix-ecom-backend"; As shown here, and mentioned by @onemoretime

Hi, I still get the error even though I made that adjustment. I’m integrating a “Bireysel Ders Satın Alma” (Individual Lesson Purchase) page on my Wix site. The page loads correctly, displays languages, lessons, and teachers via repeaters, and allows the user to select available time slots.

Problem:

  • Teacher names are not displayed in the repeater (showing “No Name”).

  • When I click the payment button, I get the following console error:

TypeError: (0 , pay_service.createCheckoutAndOrder) is not a function

Setup:

  • Backend: pay-service.jsw in Wix Velo backend

  • Frontend: Repeaters and checkbox groups to select lesson, teacher, and time slots

  • Payment: Using wix-pay and wix-ecom-backend

Backend function:

// pay-service.jsw
import wixData from 'wix-data';
import wixStores from 'wix-stores-backend';
import { checkout } from 'wix-ecom-backend';

export async function createCheckoutAndOrder(lessonData) {
    // logic to create product, checkout, and order
}

Frontend import:

import { createCheckoutAndOrder } from 'backend/pay-service';

What I observe:

  • Console logs confirm that lesson, language, and teacher data are correctly fetched.

  • The lessonData object passed to the backend is:

{
  "lessonId": "f2101197-f1c3-4b9b-9daf-defd4f2cb6e4",
  "languageId": "e2333bfa-ed18-40d8-a841-7ada3bf779d6",
  "teacherId": "f918c22c-69f2-426c-adeb-3b0bf6943353",
  "selectedSlotValues": ["Monday-09:00-10:00", "Tuesday-11:00-12:00"],
  "numberOfWeeks": 10
}

Expected behavior:

  • Teacher names displayed correctly in repeater.

  • Payment flow starts successfully and redirects the user to Wix Pay checkout.

Question:
Has anyone encountered the (0 , pay_service.createCheckoutAndOrder) is not a function error when calling a .jsw backend function from frontend in Wix Velo? How can I fix this so the frontend recognizes the function?

Thanks in advance for any guidance!

When I get support from artificial intelligence, they always end up finding the fault on Wix’s side.

Generally speaking, I would encourage to use .web.js (Web Methods) - Velo Wix Web Module Introduction | Velo - rather than .jsw, as these are deprecated.

I’m a little confused on the intended flow - since wix-pay is generally used with wix-pay-backend to create payments - Start Payment | Velo

And as far as I remember, when importing from the backend, you need to include the file type. So:

  • This import { createCheckoutAndOrder } from 'backend/pay-service';
  • Would be import { createCheckoutAndOrder } from 'backend/pay-service.jsw';