问题描述
我已经按照官方角度documentation中给出的说明创建了角度库。构建库后,使用ng build my-lib,我使用npm link命令在本地链接。
此后,在我单独的Ionic 5项目中,我通过从根文件夹运行命令来链接新创建的库: npm link my-lib
到这里一切都工作正常,我能够成功地将库导入Ionic 5项目并运行。
此后,我对库项目进行了一些更改,并运行了 ng build my-lib 命令来重建项目,它给了我以下错误:
ng build my-lib
Building Angular Package
Building entry point 'my-lib'
Compiling TypeScript sources through ngc
BUILD ERROR
node_modules/@angular/core/src/linker/compiler.d.ts(71,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/linker/compiler.d.ts(72,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
node_modules/@angular/core/src/application_ref.d.ts(145,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/application_ref.d.ts(146,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
node_modules/@angular/core/src/application_ref.d.ts(312,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/application_ref.d.ts(313,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(39,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.d.ts(40,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
node_modules/@angular/core/src/application_init.d.ts(29,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/application_init.d.ts(30,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
node_modules/@angular/core/src/testability/testability.d.ts(90,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/testability/testability.d.ts(91,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
node_modules/@angular/core/src/testability/testability.d.ts(134,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/testability/testability.d.ts(135,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
node_modules/@angular/core/src/application_module.d.ts(32,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵNgModuleDefWithMeta'.
node_modules/@angular/core/src/application_module.d.ts(33,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectorDef'.
node_modules/@angular/core/src/console.d.ts(12,25): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵFactoryDef'.
node_modules/@angular/core/src/console.d.ts(13,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
Error: node_modules/@angular/core/src/linker/compiler.d.ts(71,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
at Object.<anonymous> (/Documents/project/frontend/my-workspace/node_modules/ng-packagr/lib/ngc/compile-source-files.js:65:19)
at Generator.next (<anonymous>)
at fulfilled (/Documents/project/frontend/my-workspace/node_modules/ng-packagr/lib/ngc/compile-source-files.js:4:58)
node_modules/@angular/core/src/linker/compiler.d.ts(71,26): error TS2694: Namespace '"/Documents/project/frontend/my-workspace/node_modules/@angular/core/src/r3_symbols"' has no exported member 'ɵɵInjectableDef'.
at Object.<anonymous> (/Documents/project/frontend/my-workspace/node_modules/ng-packagr/lib/ngc/compile-source-files.js:65:19)
at Generator.next (<anonymous>)
at fulfilled (/Documents/project/frontend/my-workspace/node_modules/ng-packagr/lib/ngc/compile-source-files.js:4:58)
{
"compilerOptions": {
// ...
// paths are relative to `baseUrl` path.
"paths": {
"@angular/*": [
"./node_modules/@angular/*"
]
}
}
}
但仍然出现相同的错误。
以下是我的ng版本信息:
LTM027118:my-workspace ptiwari$ ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__,|\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 7.3.10
Node: 10.15.1
OS: darwin x64
Angular: 7.2.16
... animations,common,compiler,compiler-cli,core,forms
... language-service,platform-browser,platform-browser-dynamic
... router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.13.10
@angular-devkit/build-angular 0.13.10
@angular-devkit/build-ng-packagr 0.13.10
@angular-devkit/build-optimizer 0.13.10
@angular-devkit/build-webpack 0.13.10
@angular-devkit/core 7.3.10
@angular-devkit/schematics 7.3.10
@angular/cli 7.3.10
@ngtools/json-schema 1.1.0
@ngtools/webpack 7.3.10
@schematics/angular 7.3.10
@schematics/update 0.13.10
ng-packagr 4.7.1
rxjs 6.3.3
typescript 3.2.4
webpack 4.29.0
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)