I upgraded from Angular 9.17 to 9.19 and now ng build fails with the following error complaining about a variable declaration in both @types/node and zone.js:
ERROR in node_modules/@types/node/ts3.5/globals.global.d.ts:1:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'global' must be of type 'Global', but here has type 'Global & typeof globalThis'.
1 declare var global: NodeJS.Global & typeof globalThis; ~~~~~~
node_modules/zone.js/dist/zone.js.d.ts:600:13 600 declare var global: NodeJS.Global; ~~~~~~ 'global' was also declared here.
It was working fine before upgrading and now won't build. This was the only change.
Please help.
My package.json
{
"name": "myapp",
"private": true,
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "echo hello && ng serve --live-reload=false",
"build": "node --max_old_space_size=4096 ng build",
"build:ssr": "ng run MIC:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"postcss": {},
"dependencies": {
"@angular-devkit/schematics": "9.1.7",
"@angular/animations": "9.1.9",
"@angular/cdk": "9.2.4",
"@angular/common": "9.1.9",
"@angular/compiler": "9.1.9",
"@angular/core": "9.1.9",
"@angular/flex-layout": "9.0.0-beta.31",
"@angular/forms": "9.1.9",
"@angular/localize": "9.1.9",
"@angular/material": "9.2.4",
"@angular/material-moment-adapter": "9.2.4",
"@angular/platform-browser": "9.1.9",
"@angular/platform-browser-dynamic": "9.1.9",
"@angular/platform-server": "9.1.9",
"@angular/router": "9.1.9",
"@fortawesome/angular-fontawesome": "0.6.1",
"@fortawesome/fontawesome-svg-core": "1.2.28",
"@fortawesome/free-regular-svg-icons": "5.13.0",
"@fortawesome/free-solid-svg-icons": "5.13.0",
"@microsoft/signalr": "3.1.4",
"@microsoft/signalr-protocol-msgpack": "3.1.4",
"@ng-bootstrap/ng-bootstrap": "6.1.0",
"@ng-select/ng-select": "4.0.0",
"@nguniversal/module-map-ngfactory-loader": "9.0.0-next.9",
"@swimlane/ngx-charts": "14.0.0",
"@syncfusion/ej2-angular-buttons": "18.1.52",
"@syncfusion/ej2-angular-calendars": "18.1.53",
"@syncfusion/ej2-angular-dropdowns": "18.1.54",
"@syncfusion/ej2-angular-splitbuttons": "18.1.52",
"angular-dual-listbox": "5.0.1",
"angular2-notifications": "9.0.0",
"aspnet-prerendering": "3.0.1",
"bootstrap": "4.5.0",
"classlist.js": "1.1.20150312",
"core-js": "3.6.5",
"date-fns": "2.14.0",
"hammer-timejs": "1.1.0",
"hammerjs": "2.0.8",
"hash-sum": "2.0.0",
"immutable": "4.0.0-rc.12",
"intl": "1.2.5",
"jquery": "3.5.1",
"jwt-decode": "2.2.0",
"material-design-icons": "3.0.1",
"moment": "2.26.0",
"ng-validator": "2.0.0",
"ngx-material-timepicker": "5.5.2",
"ngx-print": "1.2.0-beta.4",
"oidc-client": "1.10.1",
"popper.js": "1.16.1",
"primeicons": "3.0.0",
"primeng": "9.1.0",
"rxjs": "6.5.5",
"tippy.js": "6.2.3",
"tslib": "2.0.0",
"web-animations-js": "2.3.2",
"zone.js": "0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "0.901.7",
"@angular/cli": "9.1.7",
"@angular/compiler-cli": "9.1.9",
"@angular/language-service": "9.1.9",
"@boldreports/angular-reporting-components": "2.2.32",
"@boldreports/types": "2.2.32",
"@intervolga/optimize-cssnano-plugin": "1.0.6",
"@types/jasmine": "3.5.10",
"@types/jasminewd2": "2.0.8",
"@types/jquery": "3.3.38",
"@types/jwt-decode": "2.2.1",
"@types/node": "14.0.5",
"autoprefixer": "9.8.0",
"codelyzer": "5.2.2",
"jasmine-core": "3.5.0",
"jasmine-spec-reporter": "5.0.2",
"karma": "5.0.7",
"karma-chrome-launcher": "3.1.0",
"karma-coverage-istanbul-reporter": "3.0.2",
"karma-jasmine": "3.1.1",
"karma-jasmine-html-reporter": "1.5.4",
"karma-scss-preprocessor": "4.0.0",
"typescript": "3.8.3",
"webpack-dev-server": "3.11.0"
},
"optionalDependencies": {
"node-sass": "4.14.1",
"protractor": "7.0.0",
"tslint": "6.1.2",
"ts-node": "8.10.1"
}
}
It seems that you need to wait for new version of @types/node package. Downgrade to 14.0.4 helped me in this case (for now).
npm install @types/[email protected] --saveDev
The problem wasn't coming from @types/node
but from the zone.js
dependency from angular itself, Here for the Github related issue.
Seems know that you may upgrade your zone.js to the latest version. at least v0.11.1
npm i zone.js@latest
But, be aware of the breaking changes regrades legacy browsers such as IE11.
Feel free then to upgrade your @types/node to the latest version
npm i @types/node@latest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With