1.升級全局angular-cli
npm install -g @angular/cli@latest
2.升級項目內 angular-cli
(在需要升級的項目中運行)
npm i @angular/cli@latest
3.升級剩下的所有組件
ng update --all --force
4.更新所有需要安裝的組件
(在需要升級的項目下)
npm i
如果出現報錯信息類似於如下這種
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/array' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/date' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/function' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/map' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/math' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/number' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/object' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/parse-float' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/parse-int' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/regexp' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/set' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/string' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/symbol' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/weak-map' in 'C:\CoddingWorkspace\vehicle_insurance_pc\src'
進入polyfills.ts 更改引入路徑為如下即可
import 'core-js/features/symbol'; import 'core-js/features/object'; import 'core-js/features/function'; import 'core-js/features/parse-int'; import 'core-js/features/parse-float'; import 'core-js/features/number'; import 'core-js/features/math'; import 'core-js/features/string'; import 'core-js/features/date'; import 'core-js/features/array'; import 'core-js/features/regexp'; import 'core-js/features/map'; import 'core-js/features/weak-map'; import 'core-js/features/set';
import 'core-js/proposals/reflect-metadata';