I have been attempting to upgrade my Angular app from version 8 to version 15. After updating all the necessary packages, I encountered the following error when running the application:
Uncaught SyntaxError: Cannot use import statement outside a module (at scripts.js:1:1)
I tried various solutions that were suggested in this Stack Overflow thread, but unfortunately, none of them resolved the issue.
The solutions I attempted included adding "type = module" in package.json:
// package.json
{
"type": "module"
}
and changing the module setting to commonjs in tsconfig:
"module": "commonjs"
In addition, I installed the following packages:
1. npm i typescript --save-dev
2. npm i ts-node --save-dev
Below is a snippet of my package.json file:
{
// contents of package.json
}
and here is the content of my tsconfig file:
{
// contents of tsconfig file
}
The previous version of the application (Angular 8) worked without any issues, it's only the updated version that is causing problems. Any help or guidance on how to resolve this would be greatly appreciated. Thank you!