首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有组件样式的角库主机版本错误

带有组件样式的角库主机版本错误
EN

Stack Overflow用户
提问于 2022-01-14 18:37:52
回答 1查看 338关注 0票数 0

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

在styleUrls

  • Importing中导入.css文件,以styleUrls

  • Adding内联样式导入.scss文件

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

常春藤部分编译模式下的角源编译.

X错误无法启动服务:主机版本"0.14.11“与二进制版本"0.14.2”不匹配

只有当它完全起作用的时候,如果我不包括任何样式。我不知道我是不是在我的项目中遗漏了什么东西来完成这个工作,我是否需要更新什么,或者什么。这些组合包括:

代码语言:javascript
复制
// 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
  }
}

如果有人能在这里帮助我,那将是非常感谢的!

EN

回答 1

Stack Overflow用户

发布于 2022-01-23 21:58:58

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

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70715142

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档