just ref customElements, not by window.customElements ?
your error indicates the window is not defined, so you can't reference it. You should be able to just reference customElements
quote However, it is usually shortened to something like the following:
customElements.define( "element-details", class extends HTMLElement { ... } }, );