Capacitor sync cb.apply is not a function

Have upgraded to Capacitor 6. Using Nx for monorepo management. Had to switch from @nxtend/capacitor to @nxext/capacitor for Cap Cli integration. Using Yarn for package management cli on a Windows machine.

Unable to get past cb.apply error (command output below). From what I have read online clearing npm cache fixes the issue. Since I’m not using npm did a yarn cache clean.

I also cloned my repo fresh into a new directory and built node_modules fresh.

> nx run touch-controller:sync:android

> yarn
warning package.json: No license field
warning touch-controller: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > @capacitor-community/wifi@0.0.1" has incorrect peer dependency "@capacitor/core@^3.2.0".
warning " > usb-serial-plugin@0.0.9" has incorrect peer dependency "@capacitor/core@^4.6.1".
[4/4] Building fresh packages...
npm ERR! cb.apply is not a function
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sdunning\AppData\Roaming\npm-cache\_logs\2024-06-19T18_11_49_130Z-debug.log
Install for [ '@capacitor/cli@6.1.0' ] failed with code 1

Sounds like a node issue your having. Its hard to give the proper help without proper description of your issue. How do I ask a good question? - Help Center - Stack Overflow. with that being said heres a solution you can try:

node.js - npm ERR! cb.apply is not a function - Stack Overflow. There are several solutions in this thread, including a windows.

Yes I agree that it’s a Node issue. Suspect my Node version manager nodist is getting in the way. I think capacitor cli uses npm under the hood but have not peeked at the source for it to understand what sync(copy + update) is doing.

Yeah that was the issue. Uninstalled nodist and installed a clean version of NodeJs which got me past this problem. On to solving other gradle build issues now.

1 Like

Glad you got it worked out. btw you might wanna updgrade those capacitor plugins as well may, cause other unintended issues while upgrading: