问题
我创建了一个有角度的工作场所,其中包含一个应用程序和一个库。启用 IVY 后,在构建库时出现错误。但如果我将 enableIvy 设置为 false,它运行良好。
代码
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom"],
"paths": {
"cxi-library": ["dist/cxi-library"],
"cxi-library/*": ["dist/cxi-library/*"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"enableIvy": true
}
}
angular.json 的一部分
"cxi-library": {
"projectType": "library",
"root": "projects/cxi-library",
"sourceRoot": "projects/cxi-library/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/cxi-library/tsconfig.lib.json",
"project": "projects/cxi-library/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/cxi-library/src/test.ts",
"tsConfig": "projects/cxi-library/tsconfig.spec.json",
"karmaConfig": "projects/cxi-library/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/cxi-library/tsconfig.lib.json",
"projects/cxi-library/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
}
尝试运行 ng build cxi-library 收到如下错误:
** 不建议将 Ivy 库发布到 NPM 存储库 **
构建入口点'cxi-library'
通过 ngc 编译 TypeScript 源 ERROR: ENOENT: no such file or directory, scandir 'C:/cxi.registry.ui/cxi.registry.ui/C:/cxi.registry.ui/cxi.registry.ui/dist/cxi -library/cxi-library.d.ts' 发生未处理的异常:ENOENT: 没有这样的文件或目录,scandir 'C:/cxi.registry.ui/cxi.registry.ui/C:/cxi.registry.ui/ cxi.registry.ui/dist/cxi-library/cxi-library.d.ts' 参见“C:\Users\JUNXIL~1.FOX\AppData\Local\Temp\ng-tIrBUR\angular-errors.log”更多详细信息。