In my NX project, I have a capacitor Angular 14 application, when using cap:sync, I get the following error which stomps me.
> nx run caregiver:sync:ios --verbose=true
> NX Cannot find module 'nx/src/utils/app-root'
Require stack:
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/@nxtend/capacitor/node_modules/@nrwl/devkit/index.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/@nxtend/capacitor/src/executors/cap/executor.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/config/workspaces.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/command-line/run.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/bin/run-executor.js
Error: Cannot find module 'nx/src/utils/app-root'
Require stack:
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/@nxtend/capacitor/node_modules/@nrwl/devkit/index.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/@nxtend/capacitor/src/executors/cap/executor.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/config/workspaces.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/src/command-line/run.js
- /Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/nx/bin/run-executor.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/yannickdesjardins/Documents/GitHub/nx-c4g/nx-c4g/node_modules/@nxtend/capacitor/node_modules/@nrwl/devkit/index.js:182:18)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
My nx report is the following: I use node 16, nx 14 and capacitor 13. I have research on the subject but can't seem to find the right answer.
I had the same issue, it was difficult to find an answer online. Here is how I fixed this issue
First ran the
nx report
, then checked thenx
version and@nrwl/<package>
versions are the same.For me the
nx
version was14.4.2
and the@nrwl/react
was14.8.2
this was causing the issue I believe. Changing the version of@nrwl/react
to14.4.2
fixed it for me. I just went ahead changed the@nrwl/node
and@nrwl/js
versions to14.4.2
from14.4.3
(say that I'm cautious)