1

我正在尝试实现一个公共项目,我在其中保留了几个可重用的 Angular 组件和服务,我想将它们用于其他几个项目。我想使用 Bit 在我的项目之间共享组件(或者更确切地说是模块)。我按照教程和其他教程的说明进行操作。

以下命令都可以正常工作并且符合预期:

npm install bit-bin -g

位登录

位初始化

位添加--main src/components/content/editable/editable.image.module.ts

位状态提示如下:

new components
(use "bit tag --all [version]" to lock a version with all your changes)

    > image ... ok

当我想将 Angular 编译器导入 Bit 时,麻烦就开始了,如下所示:

位导入 bit.envs/compilers/angular --compiler

failed running npm install at /Users/SergDerbst/Development/tmt-patchbay/.git/bit/components/compilers/angular/bit.envs/10.1.7 with args: --production  
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: @bit/bit.envs.compilers.angular@10.1.7
npm ERR! Found: typescript@4.0.3
npm ERR! node_modules/typescript
npm ERR!   typescript@"4.0.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@">=3.0.0 <4.0" from @bazel/typescript@2.3.0
npm ERR! node_modules/@bazel/typescript
npm ERR!   @bazel/typescript@"2.3.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/SergDerbst/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/SergDerbst/.npm/_logs/2021-07-05T06_56_37_358Z-debug.log

我对 npm 依赖处理不太了解,但显然编译器@bit/bit.envs.compilers.angular@10.1.7将 TypeScript 4.0.3 作为其依赖项,而 Bazel 需要旧版本的 TypeScript。奇怪的是,我自己的项目有 TypeScript 4.3.15 作为 devDependency:

"dependencies": {
    "@angular/common": "^12.1.1",
    "@angular/core": "^12.1.1",
    "rxjs": "^6.6.7"
},
"devDependencies": {
    "@types/jest": "^26.0.23",
    "jest": "^27.0.4",
    "prettier": "^2.3.1",
    "ts-jest": "^27.0.3",
    "tslint": "^6.1.3",
    "tslint-config-prettier": "^1.18.0",
    "typescript": "^4.3.5"
},
"bit": {
    "env": {},
    "componentsDefaultDirectory": "components/{name}",
    "packageManager": "npm"
}

起初,我在我的项目中尝试过较旧的 TypeScript 版本或较旧版本的 Angular,但无济于事。我认为它与 Bit 角度编译器本身的依赖树有关。我可能会排除 Bazel 作为它的依赖项,但这对于 Bit 原子化 Angular 模块来说应该是必要的。我试图用谷歌搜索这个问题,但找不到其他人有这个问题。

也许这是显而易见的愚蠢的事情,我对此有一个盲点。非常感谢任何帮助或提示。

4

0 回答 0