Import wixSiteBackend from 'wix-site-backend';

suddenly not working anymore, no changes were made.
errror: Cannot find module ‘./lib/cacheInvalidator’

Help greatly appreciated

Where are you using it? On the page code or a backend file?

The correct format is for the backend code is below.

import wixSite from 'wix-site-backend';

.jsw backend file

I forgot, have you noticed, the reference cites:

import wixSite from 'wix-site-backend';

but when inserting the code in the editor and using the code completion dialog,there is only:

import wixSiteBackend from 'wix-site-backend';

@irb6

Yes then don’t use the automated completion list them as you will notice that it may insert it for you, however the code will be wrong and won’t work.


So basically do as Shan has already stated and write it as in the Wix API Reference for Wix Site or Wix Site Backend.

https://www.wix.com/corvid/reference/wix-site-backend.html
wix-site-backend
The wix-site-backend module contains functionality for obtaining information about your site and its pages from backend code.
To use the General Info API, import wixSite from the wix-site-backend module:
import wixSite from ‘wix-site-backend’;

https://www.wix.com/corvid/reference/wix-site.html
wix-site
The wix-site module contains functionality for obtaining information about your site and its pages.
To use the site module, import wixSite from the wix-site module:

import wixSite from 'wix-site';

The APIs in wix-site can only be used in front-end code.

Hi all,
So you can actually use any name to import from Wix modules, so long as you use the same name in your code.
Both of the following code snippets should work:

import wixSite from 'wix-site-backend';

export function getAddress() {
  return wixSite.generalInfo.getAddress();
}
import wixSiteBackend from 'wix-site-backend';

export function getAddress() {
  return wixSiteBackend.generalInfo.getAddress();
}

We realize that the discrepancy between the autocomplete and the documentation is confusing and will try to fix the issue. Thanks for bringing it to our attention.

@givemeawhisky thank you. Of course I tried to use the code as suggested by Shan immediately
(import wixSite from ‘wix-site-backend’:wink:
but I got the same error: Cannot find module ‘./lib/cacheInvalidator’

Hey @irb6 ,
Can you please post a link to your published site or your editor so we can take a look? Only authorized Wix personnel can access your site’s editor.

Hello @talyaro
https://editor.wix.com/html/editor/web/renderer/edit/03bb9056-32d6-444e-83c2-a28f05e3f469?metaSiteId=b3746d5a-14c3-472e-a913-5a3119fec3bf

Error loading web module backend/beta.jsw: Cannot find module ‘./lib/cacheInvalidator’

Hey @irb6 , I took a look at your site and it does seem as if something is wonky with the import of wix-site-backend. I tried both wixSite, wixSiteBackend, wixsiteBackend, and even some obsenities but nothing worked - although the obsenities made me feel better. I’m sending this on to QA for evaluation.

Hello @yisrael-wix , thank you for the effort! However, this must be something others have experienced as well?

@irb6 The thought crossed my mind. I was just thinking about trying this on one of my test sites and see if it’s something that’s just specific to your site, or there’s something more sinister going on. I’ll get back to you on this.

Well, same thing on my test site. Now it’s QA’s turn.

@irb6 Hi. Indeed, there was an issue on our side. It has been fixed just now. Thank you for letting us know!

Regards, Alex

Thank you all for your timely response and help!