我通过角13中的CLI (v13.1.0)生成了我的第一个角库,它主要使用服务,这是没有问题的。现在,我以同样的方式创建了另一个组件,一个Loader模块,但是我打算使用一个组件。生成它时,它只显示component.ts和component.spec.ts文件。当我构建库时,一切都按预期工作,没有问题。但我需要将样式应用于组件。所以我尝试了三种不同的方法:
在styleUrls
每次我试图构建库时,都会得到以下错误:
常春藤部分编译模式下的角源编译.
X错误无法启动服务:主机版本"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
}
}如果有人能在这里帮助我,那将是非常感谢的!
发布于 2022-01-23 21:58:58
在将@angular/cli和@angular-devkit/build-angular从13.1.2升级到13.1.5后,我收到了相同的错误消息。
删除现有的dist、node_modues和.angular文件夹为我解决了问题。
https://stackoverflow.com/questions/70715142
复制相似问题