Ionic cli error: package exports invalid

I develop the iShine app on linux and then transfer the latest build to a MacBook when ready. This time Ionic on the MacBook is refusing to work without error. Whenever I run it I get:

Error: Package exports for ‘/usr/local/lib/node_modules/@ionic/cli/node_modules/uuid’ do not define a valid ‘.’ target

at resolveExportsTarget (internal/modules/cjs/loader.js:545:13)
at applyExports (internal/modules/cjs/loader.js:459:14)
at resolveExports (internal/modules/cjs/loader.js:508:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:577:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:879:27)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/usr/local/lib/node_modules/@ionic/cli/lib/utils/uuid.js:3:16)
at Module._compile (internal/modules/cjs/loader.js:1063:30)

this particular instance was with ionic --help

ionic serve works as does ionic info but ionic cordova prepare ios fails so I can check it works but not transfer it to XCode for the final build.

I am using ionic 5 and the ionic info response is:

Ionic:

Ionic CLI : 6.10.0 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.1.1
@angular-devkit/build-angular : 0.901.7
@angular-devkit/schematics : 9.1.7
@angular/cli : 9.1.7
@ionic/angular-toolkit : 2.2.0

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1)
Cordova Platforms : not available
Cordova Plugins : not available

Utility:

cordova-res (update available: 0.14.0) : 0.11.0
native-run : 1.0.0

System:

ios-deploy : 1.10.0
ios-sim : 8.0.2
NodeJS : v13.1.0 (/usr/local/bin/node)
npm : 6.14.4
OS : macOS Catalina
Xcode : Xcode 11.5 Build version 11E608c

I have done the normal trick of removing and re-installing node-modules.

How should I solve this???

I have managed to fix this.

I installed node-inspect and ran node-inspect uuid.js within the relevant directory. This enabled me to single step the programme and match it to the error report. This made me suspicious that there was something wrong with node.js - maybe the wrong version.

I checked was version I was on with node -v, which was v13.1.0.

I then ran:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

This installed v12.8.0.

I can now run ionic cordova prepare ios without any errors. I only wish that I could get rid of IOS. Why will Apple not let me develop for IOS on linux???