元件样式的角度库主体版本错误



我在Angular 13(v13.1.0(中通过CLI生成了我的第一个Angular库,它主要使用服务,这没有问题。现在我以同样的方式创建了另一个Loader模块,但我打算使用一个组件。生成时,它只显示component.ts和component.spec.ts文件。当我建造图书馆时,一切都按预期进行,没有问题。但我需要将样式应用于组件。所以我尝试了3种不同的方法:

  • 在styleUrls中导入.css文件
  • 在styleUrls中导入.scs文件
  • 添加内联样式

每次我尝试构建库时,我都会得到以下错误:

在Ivy部分编译模式下使用Angular源进行编译
X[ERROR]无法启动服务:主机版本"0.14.11〃;与二进制版本"不匹配";0.14.2

唯一一次它完全有效是如果我不包括任何风格。我不知道我的项目中是否遗漏了什么,是否需要更新什么,或者什么。配置包括:

// tsconfig.lib.json
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../../../out-tsc/lib",
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"types": [],
"lib": [
"dom",
"es2018"
]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
// tsconfig.lib.prod.json
{
"extends": "./tsconfig.lib.json",
"compilerOptions": {
"declarationMap": false
},
"angularCompilerOptions": {
"compilationMode": "partial"
}
}
// library package.json
{
"name": "loader",
"version": "0.0.1",
"peerDependencies": {
"@angular/common": "^13.1.0",
"@angular/core": "^13.1.0"
},
"dependencies": {
"tslib": "^2.3.0"
}
}
// angular.json for library
"loader": {
"projectType": "library",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
}
},
"root": "projects/loader",
"sourceRoot": "projects/loader/src",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "projects/loader/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/loader/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "projects/loader/tsconfig.lib.json"
}
},
"defaultConfiguration": "production"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/loader/src/test.ts",
"tsConfig": "projects/loader/tsconfig.spec.json",
"karmaConfig": "projects/loader/karma.conf.js"
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": [
"projects/loader/**/*.ts",
"projects/loader/**/*.html"
]
}
}
}
}
// main tsconfig.ts file
{
"compileOnSave": false,
"compilerOptions": {
"paths": {
"loader": [
"dist/loader/app-loader",
"dist/loader"
]
},
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"resolveJsonModule": true,
"target": "es2017",
"module": "es2020",
"lib": [
"es2020",
"dom"
]
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}

如果有人能在这里帮我,我将不胜感激!

在将@angular/cli@angular-devkit/build-angular113.1.2升级到1.1.5后,我收到了相同的错误消息。

删除现有的distnode_modues.angular文件夹为我解决了这个问题

相关内容

最新更新