AnandChowdhary / calendar-link

📅 Calendar link generator for popular services

Home Page:https://anandchowdhary.github.io/calendar-link/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught ReferenceError: exports is not defined

tkurosaka opened this issue · comments

Sorry, this is probably a novice's question.

I put
<script src="https://cdn.jsdelivr.net/npm/calendar-link@1.2.5/dist/index.min.js"></script>
in html/header section of my test html file, and opened the file statically (as a file, not served)
then the js console reported "Uncaught ReferenceError: exports is not defined at index.js:16"
The same error happened on Chrome and Opera.

Do I need to include other libraries before this line perhaps?

I also tried the latest version (hopefully) by getting a local copy with npm install. This time, "Uncaught ReferenceError" didn't happen but I was told calendarLink is not defined.

I have the same error but found solution.

Include this script <script src="https://cdn.jsdelivr.net/npm/calendar-link/dist/index.umd.js"></script>

Then use code like in example:

 <a class="atc-link icon-google" target="_blank" data-calendar-link="google" href="#">Google Calendar</a>
  <a class="atc-link icon-ics" target="_blank" data-calendar-link="ics" href="#">iCal</a>
<a class="atc-link icon-ical" target="_blank" data-calendar-link="outlook" href="#">Outlook Calendar</a>
<a class="atc-link icon-yahoo" target="_blank" data-calendar-link="yahoo" href="#">Yahoo! Calendar</a>
 <a class="atc-link icon-office365" target="_blank" data-calendar-link="office365" href="#">Office 365</a>
<script>
  const event = {
   start: "2021-08-29T15:00:00+0300",
  duration: [1, "hour"],
  title: "Title",
  description: "",
  location: "Internet",
   busy: true
  };
  const calendarLinkElements = document.querySelectorAll("[data-calendar-link]");
  calendarLinkElements.forEach(link => {
  link.setAttribute("href", (calendarLink[link.getAttribute("data-calendar-link")](event)));
   });
</script>

@darkvovich , is it possible for you to attach a complete HTML file that works? I am not sure where this <script> to go, in or , and where the import statement goes. I tried different combinations but none worked for me.

I can confirm this problem. This library is useless with this bug, I can't get it to work at all. It's not compatible with plain 'ol javascript, apparently. Using the UMD version did not work either.

⚠️ This issue has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

⚠️ This issue has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.