Disclaimer: I have always found package dependencies a bit of a mystery!
We have an Angular 13 / Ionic 6 / Capacitor 4 app and we use AppFlow.
Currently the app is building fine locally but on AppFlow the build is failing and I don’t really understand why there is a difference between the two.
The app has a dependency on the ionic-appauth library which has, as an optional dependency, the @awesome-cordova-plugins/secure-storage plugin i.e :
"optionalDependencies": {
"@awesome-cordova-plugins/secure-storage": "^5.46.0",
}
The AppFlow error when building is:
Error: node_modules/ionic-appauth/lib/cordova/cordova-secure-storage.d.ts:2:37 - error TS2307: Cannot find module '@awesome-cordova-plugins/secure-storage' or its corresponding type declarations.
2 import { SecureStorageObject } from '@awesome-cordova-plugins/secure-storage';
So if I’m understanding optional dependencies correctly it would appear that when AppFlow runs its npm install this dependency is not being installed, otherwise the build would not fail with the above error.
But locally (and I have the same Node and NPM versions as the AppFlow build stack) if I run npm install and npm build I get no errors.
What would cause this?