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:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/date' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/function' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/map' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/math' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/number' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/object' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/parse-float' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/parse-int' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/regexp' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/set' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/string' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/symbol' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
ERROR in ./src/polyfills.ts
Module not found: Error: Can't resolve 'core-js/es6/weak-map' in 'C:CoddingWorkspacevehicle_insurance_pcsrc'
进入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';