I have created Angular app(v-18.0.6) with command “ng new myapp” which runs perfectly in my local environment. When I ran the app in emulator(pixel 7 API 30, pixel 7 API 30 and etc) of android studio by using capacitor I got the following error in the Chrome(chrome://inspect/#devices).
SyntaxError: Unexpected token ‘{’
polyfills-6UXIKGYX.js:1 Uncaught SyntaxError: Unexpected token ‘{’
SyntaxError: Unexpected token ‘=’
cap.handleError
main-AE5OQ3WL.js:1 Uncaught SyntaxError: Unexpected token ‘=’
favicon.ico:1 GET https://localhost/favicon.ico 404 (Not Found)
my operating system is windows 11. I have tried node versions of 18.20.4, 20.17, 21.7.3 and have updated the emulator to latest version but got the same error. The target of tsconfig.json is “target”: “ES2022”.
Used following commands to create angular app and add capacitor to my project
- ng new myapp
- npm i @capacitor/core
- npm i @capacitor/cli --save-dev
- npx cap init
- npm i @capacitor/android
- ng build
- changed “webDir” to “dist/myproject/browser” in capacitor.config.ts
- npx cap add android
- npx cap open android