Closed Rojac closed 3 years ago
通过验证,使用cli 11.0.3与11.0.4 新建项目后,按DevUI快速开始引入后,build正常。 我们使用cli新建项目package.json依赖如下,可对比当前是否typescript版本与你的项目存在不一致:
"dependencies": {
"@angular/animations": "~11.0.3",
"@angular/common": "~11.0.3",
"@angular/compiler": "~11.0.3",
"@angular/core": "~11.0.3",
"@angular/forms": "~11.0.3",
"@angular/platform-browser": "~11.0.3",
"@angular/platform-browser-dynamic": "~11.0.3",
"@angular/router": "~11.0.3",
"ng-devui": "^10.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1100.3",
"@angular/cli": "~11.0.3",
"@angular/compiler-cli": "~11.0.3",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.1.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}
更多地,可尝试删除package-lock.json与node_modeules后,重新安装依赖后进行build操作。
"dependencies": { "@angular/animations": "~11.0.4", "@angular/common": "~11.0.4", "@angular/compiler": "~11.0.4", "@angular/core": "~11.0.4", "@angular/forms": "~11.0.4", "@angular/platform-browser": "~11.0.4", "@angular/platform-browser-dynamic": "~11.0.4", "@angular/router": "~11.0.4", "@devui-design/icons": "^1.2.0", "ng-devui": "^10.1.0", "rxjs": "~6.6.0", "tslib": "^2.0.0", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "~0.1100.4", "@angular/cli": "~11.0.4", "@angular/compiler-cli": "~11.0.4", "@types/jasmine": "~3.6.0", "@types/node": "^12.11.1", "codelyzer": "^6.0.0", "jasmine-core": "~3.6.0", "jasmine-spec-reporter": "~5.0.0", "karma": "~5.1.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.0", "karma-jasmine-html-reporter": "^1.5.0", "protractor": "~7.0.0", "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "~4.0.2" } 配置看上去并没有问题,但ng build还是报错。在app.module.ts文件中加上ng-devui引用就报错 import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core';
import { DevUIModule } from 'ng-devui';
import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component';
@NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, BrowserAnimationsModule, DevUIModule, AppRoutingModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
当创建Angular项目时,Angular routing选择No,如下: Would you like to add Angular routing? No 再按官网加配置就不会报上面的错误。但会出现如下的警告: Warning: D:\WorkDir\ISource\Web\WebBSPortal\node_modules\ng-devui__ivy_ngcc__\fesm2015\ng-devui-theme.js depends on 'enquire.js'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
Warning: D:\WorkDir\ISource\Web\WebBSPortal\node_modules\ng-devui__ivy_ngcc__\fesm2015\ng-devui-utils.js depends on 'date-fns/format'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
Warning: D:\WorkDir\ISource\Web\WebBSPortal\node_modules\ng-devui__ivy_ngcc__\fesm2015\ng-devui-utils.js depends on 'date-fns/parse'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
与 #77 重复
Error: node_modules/ng-devui/form/validator-directive/validate.type.d.ts:14:5 - error TS2411: Property 'id' of type 'string | undefined' is not assignable to string index type 'string | number | boolean | RegExp | ValidatorFn | DValidatorFn'.
14 id?: string; ~~ node_modules/ng-devui/form/validator-directive/validate.type.d.ts:15:5 - error TS2411: Property 'validator' of type 'ValidatorFn | DValidatorFn | undefined' is not assignable to string index type 'string | number | boolean | RegExp | ValidatorFn | DValidatorFn'.
15 validator?: DValidatorFn | ValidatorFn;
node_modules/ng-devui/form/validator-directive/validate.type.d.ts:17:5 - error TS2411: Property 'errorStrategy' of type '"pristine" | "dirty" | undefined' is not assignable to string index type 'string | number | boolean | RegExp | ValidatorFn | DValidatorFn'.
17 errorStrategy?: DValidationErrorStrategy;
node_modules/ng-devui/form/validator-directive/validate.type.d.ts:19:5 - error TS2411: Property 'isNgValidator' of type 'boolean | undefined' is not assignable to string index type 'string | number | boolean | RegExp | ValidatorFn | DValidatorFn'.
19 isNgValidator?: boolean;
node_modules/ng-devui/form/validator-directive/validate.type.d.ts:24:5 - error TS2411: Property 'id' of type 'string | undefined' is not assignable to string index type 'string | number | boolean | RegExp | AsyncValidatorFn | DAsyncValidatorFn'.
24 id?: string; ~~ number | boolean | RegExp | AsyncValidatorFn | DAsyncValidatorFn'.
25 validator?: DAsyncValidatorFn | AsyncValidatorFn;
node_modules/ng-devui/form/validator-directive/validate.type.d.ts:27:5 - error TS2411: Property 'errorStrategy' of type '"pristine" | "dirty" | undefined' is not assignable to string index type 'string | number | boolean | RegExp | AsyncValidatorFn | DAsyncValidatorFn'.
27 errorStrategy?: DValidationErrorStrategy;
node_modules/ng-devui/form/validator-directive/validate.type.d.ts:29:5 - error TS2411: Property 'isNgValidator' of type 'boolean | undefined' is not assignable to string index type 'string | number | boolean | RegExp | AsyncValidatorFn | DAsyncValidatorFn'.
29 isNgValidator?: boolean;