'Uncaught TypeError after upgrading Angular v12 to v13

I am struggling with the following error:

Uncaught TypeError: (0 , tslib__WEBPACK_IMPORTED_MODULE_2__.__decorate) is not a function
    at Module.2200 (app.service.ts:14)
    at __webpack_require__ (bootstrap:19)
    at Module.5921 (material.module.ts:62)
    at __webpack_require__ (bootstrap:19)
    at Module.3259 (app.module.ts:125)
    at __webpack_require__ (bootstrap:19)
    at Module.3696 (main.js:18)
    at __webpack_require__ (bootstrap:19)
    at Module.4750 (app.component.ts:20)
    at __webpack_require__ (bootstrap:19)

This happened after I upgraded from v12 to v13. I already had other issues, which I fixed, like - Getting Module not found error when upgrade angular v12 to v13.

This is how my app.service.ts file looks like - https://stackblitz.com/edit/angular-ivy-3siaqz?file=src/app/app.service.ts, and the error is Uncaught TypeError



Solution 1:[1]

Please delete your node.js file and reinstall

Solution 2:[2]

I succeeded to fix it when deleting not only the node_modules, but also the package-lock.json file, then I updated the npm version to the latest one (probably not needed) and ran:

npm install –legacy-peer-deps

Then the app was working properly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 minabagheri
Solution 2 Vitomir