NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.86k stars 3.91k forks source link

NG-ZORRO v9 升级指南 / v9 upgrade guide #5035

Closed hsuanxyz closed 3 years ago

hsuanxyz commented 4 years ago

中文版

本指南适用于当前版本 ng-zorro-antd >= 8 ; 如果在升级过程中遇到问题,欢迎提出。提问前请阅读 如何向开源社区提问题 如果发现本指南存在遗漏/错误,请指出! 或者你遇到了新的问题并解决了,欢迎补充!

开始之前

  1. 首先确保你 Node.js >= 10.13
  2. 创建新的分支,或者使用其他方式备份当前项目
  3. 删除项目下 package-lock.json 文件

升级步骤

第一步 - 升级相关依赖

第二步 - 升级 NG-ZORRO

常见问题


English Version

This guide applies to the current version ng-zorro-antd> = 8; If you encounter problems during the upgrade process, feel free to comment here. If you find any errors in this guide, please point out Or you have encountered a new problem and solved it, welcome to comment here.

Before upgrade

  1. Make sure Node.js >= 10.13.
  2. Create a new branch, or use other methods to back up the current project.
  3. Delete the package-lock.json file.

Upgrade dependencies

Upgrade NG-ZORRO

Common Problem


BrsJsk commented 4 years ago

English version?

vthinkxie commented 4 years ago

English version?

updated

BrsJsk commented 4 years ago

Anyone knows why ng update @angular/cdk updates @angular/common, @angular/compiler, @angular/core and @angular/forms to version ~10.0.0-next.2 ?

nightRainStars commented 4 years ago

Ng-Zorro安装后运行发生record.factory is not a function是什么原因

hsuanxyz commented 4 years ago

@zhang0101 hope it helps you, https://github.com/angular/angular/issues/35282

nishizhen commented 4 years ago

ng update ng-zorro-antd
Using package manager: 'npm' Collecting installed dependencies... Found 37 dependencies. Fetching dependency metadata from registry... Updating package.json with dependency ng-zorro-antd @ "9.2.1" (was "8.3.1")... UPDATE package.json (1898 bytes) ✔ Packages installed successfully. Executing migrations of package 'ng-zorro-antd'

❯ Updates NG-ZORRO to v9 [https://github.com/NG-ZORRO/ng-zorro-antd/issues/5035] ✖ Migration failed: Cannot read property 'startTag' of undefined See "/private/var/folders/w0/r_snx5vx6y1c9vfwx1vzfbwh0000gn/T/ng-wNDsTu/angular-errors.log" for further details.

private/var/folders/w0/r_snx5vx6y1c9vfwx1vzfbwh0000gn/T/ng-wNDsTu/angular-errors.log: [error] TypeError: Cannot read property 'startTag' of undefined at /Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/ng-zorro-antd/schematics/utils/ng-update/elements.js:23:63 at Array.map () at Object.findElementWithTag (/Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/ng-zorro-antd/schematics/utils/ng-update/elements.js:23:21) at deprecatedComponent (/Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/ng-zorro-antd/schematics/ng-update/upgrade-rules/checks/form-template-rule.js:12:24) at FormTemplateRule.visitTemplate (/Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/ng-zorro-antd/schematics/ng-update/upgrade-rules/checks/form-template-rule.js:22:9) at /Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/@angular/cdk/schematics/update-tool/index.js:85:47 at Array.forEach () at /Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/@angular/cdk/schematics/update-tool/index.js:85:32 at Array.forEach () at UpdateProject.migrate (/Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/@angular/cdk/schematics/update-tool/index.js:80:49) at runMigrations (/Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/@angular/cdk/schematics/ng-update/devkit-migration-rule.js:136:46) at Object. (/Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/@angular/cdk/schematics/ng-update/devkit-migration-rule.js:91:21) at Generator.next () at /Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/@angular/cdk/schematics/ng-update/devkit-migration-rule.js:14:71 at new Promise () at __awaiter (/Users/tt/Projects/App.Broker.Web/BrokerWeb/node_modules/@angular/cdk/schematics/ng-update/devkit-migration-rule.js:10:12)

hsuanxyz commented 4 years ago

@nishizhen we cannot reproduce this error, could you provide a repo for us to checks? Maybe the problem is in the nz-dropdown, nz-dropdown-button, nz-form-extra and nz-tooltip, nz-popover, nz-popconfirm tags.

nishizhen commented 4 years ago

@nishizhen we cannot reproduce this error, could you provide a repo for us to checks? Maybe the problem is in the nz-dropdown, nz-dropdown-button, nz-form-extra and nz-tooltip, nz-popover, nz-popconfirm tags.

Thx, we have resolved~

yourival commented 4 years ago

I got those issues when I was trying to upgrade to v9. All date-related components are not working. I did upgrade the date-fns to 2.x before the upgrade. Please Help!

02 01 03

hsuanxyz commented 4 years ago

@yourival

error TypeError: Cannot read property 'slice' of undefined at generateTheme ...

reinstall antd-theme-generator@1.2.2


ERROR TypeError: date_fns_addMonths_WEBPACK_IMPORTED_MODULE_0__default(...) is not a function ...

@wenqi73 can you check it?

wenqi73 commented 4 years ago

@yourival Could you provide a mini reproduction?

Endran commented 4 years ago

@nishizhen we cannot reproduce this error, could you provide a repo for us to checks? Maybe the problem is in the nz-dropdown, nz-dropdown-button, nz-form-extra and nz-tooltip, nz-popover, nz-popconfirm tags.

Thx, we have resolved~

I also run into Cannot read property 'startTag' of undefined, could you explain how you resolved it?

Endran commented 4 years ago

Found it, in our case we still had nz-form-explain somewhere. I found it by replacing line 23 of node_modules/ng-zorro-antd/schematics/utils/ng-update/elements.js with the snippet below, whilst running ng update ng-zorro-antd.

  return elements.map((element) => {
    console.log(`element.nodeName ` + element.nodeName);
    return element.sourceCodeLocation.startTag.startOffset;
  });
crossan007 commented 2 years ago

I also run into Cannot read property 'startTag' of undefined, could you explain how you resolved it?

I downgraded my local install of NodeJS from 16 to 12, and I was able to run the ng-zorro-antd upgrade with:

cmd /C "set 'NG_DISABLE_VERSION_CHECK=1' && npx @angular/cli@9 update ng-zorro-antd@9.0.0 --force"
FrogitH5 commented 2 years ago

升级angular7-9遇到报错请问如何解决 ERROR in Error: Internal Error: The name total is already defined in scope to be [object Object]