nativescript-schematics icon indicating copy to clipboard operation
nativescript-schematics copied to clipboard

Uncaught ReferenceError: __decorate is not defined

Open macjohnny opened this issue 3 years ago • 2 comments

Environment Provide the content of the package.json file in the project:

@nativescript/[email protected]

Describe the bug When starting the newly created app, the error Uncaught ReferenceError: __decorate is not defined occurs in the browser and the app crashes.

To Reproduce

ng new -c=@nativescript/schematics dummy-nativescript --shared
cd dummy-nativescript
ng serve

Expected behavior No error

Additional context The solution is to remove the following lines from the tsconfig.json:

    "noEmitHelpers": true, 

(Credits: https://stackoverflow.com/a/64088843)

macjohnny avatar Oct 22 '20 09:10 macjohnny

I just had the same issue but I wasn't sure if the NativeScript mobile part of the shared app needs the "noEmitHelpers": true, so instead I put "noEmitHelpers": false, into the "tsconfig.app.json" file so it would only affect the typescript compiler options of the web browser portion of the project which also fixed this issue.

rob4226 avatar Oct 26 '20 19:10 rob4226

For my newly created code-sharing Angular project, ng serve first gave me

ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es7/reflect' in ...

which I resolved by editing polyfills.ts to have import 'core-js/es/reflect'; instead of import 'core-js/es7/reflect';. (Note: my package.json has "core-js": "^3.6.0",.)

After that change, I now got Uncaught ReferenceError: __decorate is not defined, which was resolved as discussed above. After both changes, the demo app ran as expected.

EDIT: I opened #306 regarding the polyfills error. The better fix is actually to add the missing .browserslistrc file.

steamwings avatar Nov 08 '20 20:11 steamwings