Angular 升级

357 阅读1分钟

Angular 升级到最新版本

  1. 强制更新
ng update --all --force
npm audit fix

报错处理

  • node-sass 报错, 重新编译 node-sass 模块
npm rebuild node-sass
  • 查询TypeScript版本, 指令:tsc -v,发生以下报错 tsc : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\tsc.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
以管理员身份,启动 Window PowerShell, 输入指令 set-ExecutionPolicy RemoteSigned, 选择Y

image.png

  • 编译的时候报这个错误,Error: The Angular Compiler requires TypeScript >=4.2.3 and <4.4.0 but 4.4.4 was found instead.
npm i typescript@4.2.3   TypeScript >=4.2.3 and <4.4.0 版本号要在4.2.34.4.0之间;
如果还是报错,请查看package.json 里面的TypeScript 的版本号是否和当前安装的版本符合,
不符合的话,请删除package-lock.json 的文件,重新install
  • Schema validation failed with the following errors: Data path "" must NOT have additional properties(es5BrowserSupport).

    解决办法: 请删除 angular.json 中的 es5BrowserSupport: true 的配置项