// instead of window.location.pathname like we use for normal JS, add window && const current_path = window && window.location.pathname; const path_arr = current_path.split("/"); const narrGroup = path_arr[2];