Custom code error on home page is blocking publishing

I was making a simple update to my site. When I went to publish I received a Custom Code Error on my Home Page. I have never received this error and did not add any new code. I worked with Wix Customer Support and they showed me how to enter Dev mode and told me the error needed to be deleted. I am not a developer and I am not sure if I can just delete this block of code without causing harm. I am attaching a screenshot to show the error and the Build Log. Can someone help me determine what I need to delete? Thank you in advance!!

Simplest fix would be to move all your ‘import’ lines to the top of the file

They should be at the top level, not within any curly brackets {}
Line 25 is probably part of a function

It also seems though, as if $w.onReady is also part of that function, which is probably not good
Can’t suggest how to handle that without seeing the page code. Would you please paste it here?

Yep, upon inspecting your site, it looks like the code was added by accident somehow. Feel free to clear it all.

Thank you! I have tried to paste the page code but I am a new user and it limits the links I can paste, which are inside the code. I am attaching a .PNG file with the code from the Home Page - I hope this is helpful. This is definitely outside my expertise. I can pay for support if needed. I can access the code but am hesitant to change or delete anything without more guidance. Thank you again.

If you do not use a book button then, you could just delete it. the rest of the code seems to be the sample that is added to the pages
I can gladly help for free if your interested

1 Like

The only meaningful piece of code you have on your page is the last function:

import wixLocation from 'wix-location'
export function bookBtn_click() {
    wixLocation.to(wixLocation.url.replace(/(?:#.*)?$/, '#book-now'))
}

This seems to redirect to the current page, but to a certain anchor
Something to note - the native anchor link functionality only works for the legacy Wix Editor, not Wix Studio, so if you ever migrate this site, that will have to change

You can probably set the button’s destination statically using the UI rather than through code, though I’m not sure

Anyway, the code snippet I pasted can be placed instead of the page code you currently have

Thank you for this additional explanation and for your help. I really appreciate it.