Adding a provider fails: crypto.randomUUID is not a function - cc-switch
Quick fix
Upgrade to cc-switch v3.9 or newer, which adds a crypto.randomUUID fallback for older macOS; or upgrade macOS past 12.3 Monterey / 11.6.5 Big Sur.
Symptom
Section titled “Symptom”添加供应商失败:crypto.randomUUID is not a function. (In 'crypto.randomUUID()', 'crypto.randomUUID' is undefined)Adding a provider failed: crypto.randomUUID is not a function. (In 'crypto.randomUUID()', 'crypto.randomUUID' is undefined)
This comes from cc-switch calling the system Web API `crypto.randomUUID()` when adding or updating a provider. Older macOS versions (11.7.10, 12.2.1) do not provide that function, so saving a provider throws `crypto.randomUUID is not a function`. It has nothing to do with your Node version and is not a mistake in the provider config itself.
Maintainers confirmed in the related issues that `crypto.randomUUID` first arrived in macOS 12.3 Monterey and macOS 11.6.5 Big Sur, and that cc-switch 3.8.2 - 3.8.3 calls it directly. The fix was to add a fallback for older systems in v3.9; without upgrading cc-switch, you have to upgrade macOS. Some users also mention the same error when updating a provider.
Upgrade cc-switch to v3.9 or newer; maintainers confirmed that version added a `crypto.randomUUID` fallback for older macOS.
If you cannot upgrade cc-switch yet, upgrade macOS to 12.3 Monterey or 11.6.5 Big Sur or newer, so the system provides `crypto.randomUUID()` itself.
Reopen cc-switch, go back into provider management, and add or update a provider to confirm `crypto.randomUUID is not a function` no longer appears.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 4 real issues
- Which macOS version do I need to upgrade past to resolve this?
- Maintainers replied that `crypto.randomUUID` first arrived in macOS 12.3 Monterey and macOS 11.6.5 Big Sur; those versions or newer resolve it.
- Which version is compatible?
- Maintainers confirmed cc-switch v3.9 adds the fallback for older systems. If you are on 3.8.2/3.8.3, upgrade to v3.9 or newer.
- Why do I get this error even on Node 18+?
- The error comes from the system Web API `crypto.randomUUID()` and has nothing to do with your Node version — it triggers whenever an older macOS lacks that function.
- Does updating a provider throw the same error?
- Users report the same error occasionally when updating a provider. The root cause is the same — older macOS lacking `crypto.randomUUID()` — so upgrade cc-switch or the system the same way.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.