Skip to content

withClerkIOS: ClerkViewFactory.swift not found in pnpm workspaces nested 2+ levels deep #8049

@davidtiede

Description

@davidtiede

Bug report

Description

The withClerkIOS config plugin fails to find ClerkViewFactory.swift when the Expo app is nested 2+ levels deep in a pnpm workspace (e.g. apps/mobile/).

possiblePaths only checks one level up

In app.plugin.js, the possiblePaths array resolves paths relative to config.modRequest.projectRoot:

  • ./node_modules/@clerk/expo/ios/ClerkViewFactory.swift
  • ../node_modules/@clerk/expo/ios/ClerkViewFactory.swift
  • ../packages/expo/ios/ClerkViewFactory.swift

In a standard pnpm workspace monorepo like:

monorepo/
├── node_modules/@clerk/expo/   ← package hoisted here
├── apps/
│   └── mobile/                 ← projectRoot is here
├── pnpm-workspace.yaml
└── package.json

The package lives at ../../node_modules/@clerk/expo/ relative to projectRoot, which none of the possiblePaths entries cover.

Suggested fix

Replace the hardcoded paths with require.resolve to let Node's module resolution handle arbitrary nesting:

const swiftFile = require.resolve('@clerk/expo/ios/ClerkViewFactory.swift');

Or, if you want to keep the possiblePaths approach, walk up the directory tree instead of checking only one level:

let dir = config.modRequest.projectRoot;
while (dir !== path.dirname(dir)) {
  possiblePaths.push(
    path.join(dir, 'node_modules', '@clerk', 'expo', 'ios', 'ClerkViewFactory.swift')
  );
  dir = path.dirname(dir);
}

Workaround

We're using pnpm patch @clerk/expo to add the ../../node_modules/ path manually.

Environment

  • @clerk/expo: 3.1.2
  • pnpm workspaces with app at apps/mobile/
  • Expo SDK 55

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions