Search code examples
angularnativescripthybrid-mobile-appnativescript-angulartns

Unable to Create Angular Native Shared Application


I am following https://docs.nativescript.org/angular/tooling/angular-cli#installation doc to create NativaScript + Angular Shared application

I did the following

npm i -g @angular/cli

npm i -g @nativescript/schematics

then from suitable folder

ng new --collection=@nativescript/schematics my-mobile-app --shared --sample --prefix=my --style=scss

Finally landing into following error

*npm ERR! code ETARGET npm ERR! notarget No matching version found for @angular/http@~9.1.0. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist. npm ERR! notarget npm ERR! notarget It was specified as a dependency of 'my-mobile-app' npm ERR! notarget

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\username\AppData\Roaming\npm-cache_logs\2020-07-15T18_27_24_869Z-debug.log × Package install failed, see above. The Schematic workflow failed. See above.*

Can Some body help. I tried with multiple angular version @angular/cli V 8.x, 9.x, 10.x @nativescript/schematic@9


Solution

  • So it appears there is a problem with the published version of @nativescript/schematics.

    https://github.com/NativeScript/nativescript-schematics/issues/283

    There are instructions in there on how to download the latest schematics.

    After that, I ran into the following error:

    Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
     - options[0] misses the property 'patterns'. Should be:
       [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
     - options[1] misses the property 'patterns'. Should be:
       [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
     - options[2] misses the property 'patterns'. Should be:
       [non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
    ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
    

    Which was fixed by doing what is explained in: Nativescript Angular code sharing project problem with Webpack

    Which led to the project building successfully, and then

    Webpack build done!
    Project successfully prepared (android)
    Successfully transferred package.json on device emulator-5554.
    Successfully transferred runtime.js on device emulator-5554.
    Successfully transferred tns-java-classes.js on device emulator-5554.
    Restarting application on device emulator-5554...
    System.err: An uncaught Exception occurred on "main" thread.
    System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Cannot compile /data/data/org.nativescript.test/files/app/bundle.js
    System.err: SyntaxError: Unexpected identifier
    System.err: File: (file:///data/data/org.nativescript.test/files/app/bundle.js:34:144)
    

    and from there I'm stuck...

    I've tried disabling IVY and running with ivy as discussed https://github.com/NativeScript/nativescript-angular/wiki/Updating-and-developing-for-@nativescript-angular-v9-with-Ivy-or-without and have had 0 success.