This document provides solutions for common issues you might encounter when using the EventKit Node.js addon.
If you encounter build errors:
error: tool 'xcodebuild' requires Xcode
Solution: Install Xcode Command Line Tools:
xcode-select --installIf you've updated Xcode or Node.js, you might need to clean the build:
npm run clean
npm run buildIf you see errors related to missing frameworks:
ld: framework not found EventKit
Solution: Make sure you have the required frameworks installed on your system. EventKit is part of macOS, so ensure you're on macOS 10.15 or later.
If permission requests (requestFullAccessToEvents, requestFullAccessToReminders, or their simplified equivalents requestCalendarAccess, requestRemindersAccess) return false without showing a permission dialog:
Solution: Ensure your application's Info.plist includes the required privacy descriptions:
<key>NSCalendarsUsageDescription</key>
<string>Your reason for accessing calendars</string>
<key>NSRemindersUsageDescription</key>
<string>Your reason for accessing reminders</string>For Electron apps, add these to the Info.plist in your app bundle.
Solution: The user may have previously denied permission. They'll need to enable it manually in System Preferences → Security & Privacy → Privacy → Calendars/Reminders.
For testing, you can reset privacy settings:
tccutil reset Calendar [YOUR_BUNDLE_ID]
tccutil reset Reminders [YOUR_BUNDLE_ID]Solution: Make sure your application has a valid bundle identifier.
If you encounter TypeScript errors:
Property 'getCalendars' does not exist on type...
Solution: Make sure you're importing the functions and types correctly:
// Import the module and destructure methods from simple
import { simple, Calendar, ReminderList } from 'eventkit-node';
const { requestCalendarAccess, getCalendars, getCalendar } = simple;
// Use with type annotations
const eventCalendars: Calendar[] = getCalendars();
const specificCalendar: Calendar | null = getCalendar('calendar-id');If TypeScript can't find the type definitions:
Solution: Rebuild the TypeScript definitions:
npm run build:tsIf you're getting undefined or null values when accessing calendar properties:
Solution: Make sure you've been granted permission before trying to access calendars or reminders. Always check the return value of permission requests:
// Destructure methods from simple
const { requestCalendarAccess, getCalendars, getCalendar } = require('eventkit-node').simple;
const granted = await requestCalendarAccess();
if (granted) {
// Now it's safe to access calendars
const calendars = getCalendars();
// Get a specific calendar
if (calendars.length > 0) {
const calendar = getCalendar(calendars[0].id);
console.log(calendar);
}
}If you're getting empty arrays when calling getCalendars() or getReminderLists():
Solution:
- Make sure you've been granted permission
- Check if the user actually has any calendars or reminder lists set up on their system
- Try using the EventKit-like API with explicit entity type:
const eventkit = require('eventkit-node').default; const eventCalendars = eventkit.getCalendars('event'); const reminderLists = eventkit.getCalendars('reminder');
Electron apps require special handling for permissions:
Solution:
- Make sure your app is properly signed
- Include the privacy descriptions in your app's Info.plist
- Consider using Electron's
systemPreferences.askForMediaAccessbefore requesting calendar access
If you're having trouble bundling the native addon with Electron:
Solution: Make sure you're rebuilding the native modules for Electron:
npm install --save-dev electron-rebuild
./node_modules/.bin/electron-rebuildOr use a tool like electron-builder which handles native addons automatically.