After upgrading to Angular18 and running the command ‘npm run build:ssr’, I got an error: Identifier ‘parse’ has already been declared
Full error message is:
D:angular-appssampleAngularAppnode_modulescssstylelibproperties.js: Identifier 'parse' has already been declared. (5029:9)
5027 | var width_export_definition;
5028 |
> 5029 | function parse(v) {
| ^
5030 | if (String(v).toLowerCase() === 'auto') {
5031 | return 'auto';
5032 | } [plugin angular-compiler]
node_modules/cssstyle/lib/CSSStyleDeclaration.js:225:8:
225 │ require('./properties')(CSSStyleDeclaration.prototype);
╵ ~~~~~~~~~~~~~~
This error came from the "onLoad" callback registered here:
node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:322:18:
322 │ build.onLoad({ filter: /.[cm]?js$/ }, (0, load_resul...
╵ ~~~~~~
at setup (D:angular-appssampleAngularAppnode_modules@angularbuildsrctoolsesbuildangularcompiler-plugin.js:322:19)
at async handlePlugins (D:angular-appssampleAngularAppnode_modulesesbuildlibmain.js:1194:20)
I have tried:
- npm update
- removed node_modules and package-lock.json and reinstalling packages
- removed .angular cache folder
- with different types of compalierOptions in the tsconfig.json file (I have set the ‘target’ property to ES2022, ES2023, or ESNEXT)
but no result. I stuck.
I’m attaching package.json file:
{
"name": "sample-angular-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"build": "ng build",
"build:pl": "ng build --configuration=pl",
"build:it": "ng build --configuration=it",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"dev:ssr": "ng run ngIwa:serve-ssr",
"serve:ssr": "node dist/ngIwa/server/main.js",
"build:ssr": "ng build && ng run ngIwa:server",
"prerender": "ng run ngIwa:pretender",
"start": "ng serve --proxy-config ./src/proxy.conf.json",
"start:pl": "ng serve --configuration=pl --proxy-config ./src/proxy.conf.json",
"start:it": "ng serve --proxy-config ./src/proxy.conf.json --configuration=it"
},
"private": true,
"dependencies": {
"@angular/animations": "^18.2.0",
"@angular/cdk": "^18.2.0",
"@angular/common": "^18.2.0",
"@angular/compiler": "^18.2.0",
"@angular/core": "^18.2.0",
"@angular/forms": "^18.2.0",
"@angular/material": "^18.2.0",
"@angular/platform-browser": "^18.2.0",
"@angular/platform-browser-dynamic": "^18.2.0",
"@angular/platform-server": "^18.2.0",
"@angular/router": "^18.2.0",
"@angular/ssr": "^18.2.0",
"bootstrap": "^5.3.1",
"express": "^4.19.2",
"localstorage-polyfill": "^1.0.1",
"mock-browser": "^0.92.14",
"moment": "^2.30.1",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "^0.14.10"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.0",
"@angular/cli": "~18.2.0",
"@angular/compiler-cli": "^18.2.0",
"@angular/localize": "^18.2.0",
"@types/express": "^4.17.21",
"@types/jasmine": "~4.3.0",
"@types/node": "^22.4.1",
"browser-sync": "^3.0.0",
"jasmine-core": "~4.6.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "^5.5.4"
}
}
I use Node 20.16.0 and Angular CLI 18.2.0
I appreciate any help you can provide.