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';

  

05-27 06:14