为啥@angular/core/core 没有导出成员'ɵɵFactoryDe​​claration'。构建项目时抛出错误?

Posted

技术标签:

【中文标题】为啥@angular/core/core 没有导出成员\'ɵɵFactoryDe​​claration\'。构建项目时抛出错误?【英文标题】:Why is @angular/core/core has no exported member 'ɵɵFactoryDeclaration'. error thrown when build the project?为什么@angular/core/core 没有导出成员'ɵɵFactoryDe​​claration'。构建项目时抛出错误? 【发布时间】:2022-01-18 11:20:45 【问题描述】:

我有我的全局 Angular CLI 版本 (13.0.1),项目中的本地版本是 (10.2.3)。 一切都很好,我对一些组件进行了一些更改(我没有触及 package.json),当我运行我的管道(bitbucket 管道)时,我在构建步骤中遇到了这个错误:

ERROR in node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop/ngx-file-drag-drop.component.d.ts:45:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
45     static ɵfac: i0.ɵɵFactoryDeclaration<NgxFileDragDropComponent, never>;
                       ~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop/ngx-file-drag-drop.component.d.ts:46:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵComponentDeclaration'.
46     static ɵcmp: i0.ɵɵComponentDeclaration<NgxFileDragDropComponent, "ngx-file-drag-drop", never,  "disabled": "disabled"; "multiple": "multiple"; "displayFileSize": "displayFileSize"; "borderColor": "activeBorderColor"; "accept": "accept"; "emptyPlaceholder": "emptyPlaceholder"; ,  "valueChanged": "valueChanged"; , never, never>;
                       ~~~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/byte.pipe.d.ts:7:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
7     static ɵfac: i0.ɵɵFactoryDeclaration<BytePipe, never>;
                      ~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/byte.pipe.d.ts:8:22 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵPipeDeclaration'.
8     static ɵpipe: i0.ɵɵPipeDeclaration<BytePipe, "byte">;
                       ~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop.module.d.ts:9:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
9     static ɵfac: i0.ɵɵFactoryDeclaration<NgxFileDragDropModule, never>;
                      ~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop.module.d.ts:10:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵNgModuleDeclaration'.
10     static ɵmod: i0.ɵɵNgModuleDeclaration<NgxFileDragDropModule, [typeof i1.NgxFileDragDropComponent, typeof i2.BytePipe], [typeof i3.CommonModule, typeof i4.MatChipsModule, typeof i5.MatIconModule, typeof i6.MatTooltipModule], [typeof i1.NgxFileDragDropComponent, typeof i2.BytePipe]>;
                       ~~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop.module.d.ts:11:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectorDeclaration'.
11     static ɵinj: i0.ɵɵInjectorDeclaration<NgxFileDragDropModule>;
                       ~~~~~~~~~~~~~~~~~~~~~
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@1.0.1 build: `ng build --prod --build-optimizer=false`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the client@1.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-12-14T17_41_21_825Z-debug.log

当我运行我的项目时,我在本地重现了这个错误,但它仍然存在!尽管我删除了节点模块,package-lock.json。当我切换到分支时,问题仍然存在,不包含新的更改,我删除了节点模块,package-lock.json。

错误:

+ npm run build
> client@1.0.1 build /opt/atlassian/pipelines/agent/build/new-client
> ng build --prod --build-optimizer=false
Warning: Entry point 'ngx-highlightjs' contains deep imports into '/opt/atlassian/pipelines/agent/build/new-client/node_modules/highlight.js/lib/highlight.js'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
Compiling @angular/cdk/keycodes : es2015 as esm2015
Compiling @angular/core : es2015 as esm2015
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/cdk/observers : es2015 as esm2015
Compiling @angular/animations/browser : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/cdk/collections : es2015 as esm2015
Compiling @angular/cdk/platform : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/cdk/bidi : es2015 as esm2015
Compiling @angular/forms : es2015 as esm2015
Compiling @angular/cdk/a11y : es2015 as esm2015
Compiling @angular/platform-browser/animations : es2015 as esm2015
Compiling @angular/cdk/scrolling : es2015 as esm2015
Compiling @angular/cdk/portal : es2015 as esm2015
Compiling @angular/common/http : es2015 as esm2015
Compiling @ngrx/store : es2015 as esm2015
Compiling @angular/material/core : es2015 as esm2015
Compiling @angular/cdk/layout : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/cdk/text-field : es2015 as esm2015
Compiling @angular/cdk/overlay : es2015 as esm2015
Compiling @angular/cdk/table : es2015 as esm2015
Compiling @angular/material/form-field : es2015 as esm2015
Compiling @angular/material/button : es2015 as esm2015
Compiling @angular/material/tooltip : es2015 as esm2015
Compiling @angular/material/dialog : es2015 as esm2015
Compiling @angular/material/select : es2015 as esm2015
Compiling @angular/material/input : es2015 as esm2015
Compiling @angular/material/sort : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
Compiling @ngx-translate/core : es2015 as esm2015
Compiling @angular/material/progress-spinner : es2015 as esm2015
Compiling angular-in-memory-web-api : module as esm5
Compiling @angular/material/paginator : es2015 as esm2015
Compiling ngx-perfect-scrollbar : module as esm5
Compiling ng-inline-svg : module as esm5
Compiling ngx-permissions : es2015 as esm2015
Compiling @ngrx/effects : es2015 as esm2015
Compiling @ngrx/router-store : es2015 as esm2015
Compiling @ngrx/store-devtools : es2015 as esm2015
Compiling @angular/material/snack-bar : es2015 as esm2015
Compiling @ngrx/entity : es2015 as esm2015
Compiling @angular/material/progress-bar : es2015 as esm2015
Compiling @angular/material/tabs : es2015 as esm2015
Compiling @ng-bootstrap/ng-bootstrap : es2015 as esm2015
Compiling @ngx-loading-bar/core : es2015 as esm2015
Compiling @angular/material/autocomplete : es2015 as esm2015
Compiling @angular/material/card : es2015 as esm2015
Compiling @angular/material/checkbox : es2015 as esm2015
Compiling @angular/material/datepicker : es2015 as esm2015
Compiling @angular/material/icon : es2015 as esm2015
Compiling @angular/material/menu : es2015 as esm2015
Compiling @angular/material/radio : es2015 as esm2015
Compiling @angular/material/table : es2015 as esm2015
Compiling ngx-markdown : es2015 as esm2015
Compiling ngx-captcha : es2015 as esm2015
Compiling ngx-mask : es2015 as esm2015
Compiling @angular/material-moment-adapter : es2015 as esm2015
Compiling ngx-highlightjs : es2015 as esm2015
Compiling @angular/cdk/accordion : es2015 as esm2015
Compiling @angular/material/expansion : es2015 as esm2015
Compiling @ng-select/ng-select : es2015 as esm2015
Compiling ngx-spinner : es2015 as esm2015
Compiling ngx-textarea-autosize : es2015 as esm2015
Compiling ngx-autosize : es2015 as esm2015
Compiling @angular/material/slide-toggle : es2015 as esm2015
Compiling @angular/material/chips : es2015 as esm2015
Compiling angular2-text-mask : main as commonjs
Compiling @angular/material/divider : es2015 as esm2015
Compiling @angular/fire : es2015 as esm2015
Compiling @angular/fire/firestore : es2015 as esm2015
Compiling ngx-dropzone : es2015 as esm2015
Compiling @ngx-formly/core : es2015 as esm2015
Compiling @ngx-formly/material/form-field : es2015 as esm2015
Compiling @ngx-formly/material/input : es2015 as esm2015
Compiling @ngx-formly/material/textarea : es2015 as esm2015
Compiling @ngx-formly/core/select : es2015 as esm2015
Compiling @ngx-formly/material/radio : es2015 as esm2015
Compiling @ngx-formly/material/checkbox : es2015 as esm2015
Compiling @ngx-formly/material/multicheckbox : es2015 as esm2015
Compiling @ngx-formly/material/select : es2015 as esm2015
Compiling @ngx-formly/material : es2015 as esm2015
WARNING in Entry point 'angular2-text-mask' contains deep imports into '/opt/atlassian/pipelines/agent/build/new-client/node_modules/text-mask-core/dist/textMaskCore'. This is probably not a problem, but may cause the compilation of entry points to be out of order.
ERROR in node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop/ngx-file-drag-drop.component.d.ts:45:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
45     static ɵfac: i0.ɵɵFactoryDeclaration<NgxFileDragDropComponent, never>;
                       ~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop/ngx-file-drag-drop.component.d.ts:46:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵComponentDeclaration'.
46     static ɵcmp: i0.ɵɵComponentDeclaration<NgxFileDragDropComponent, "ngx-file-drag-drop", never,  "disabled": "disabled"; "multiple": "multiple"; "displayFileSize": "displayFileSize"; "borderColor": "activeBorderColor"; "accept": "accept"; "emptyPlaceholder": "emptyPlaceholder"; ,  "valueChanged": "valueChanged"; , never, never>;
                       ~~~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/byte.pipe.d.ts:7:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
7     static ɵfac: i0.ɵɵFactoryDeclaration<BytePipe, never>;
                      ~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/byte.pipe.d.ts:8:22 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵPipeDeclaration'.
8     static ɵpipe: i0.ɵɵPipeDeclaration<BytePipe, "byte">;
                       ~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop.module.d.ts:9:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'.
9     static ɵfac: i0.ɵɵFactoryDeclaration<NgxFileDragDropModule, never>;
                      ~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop.module.d.ts:10:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵNgModuleDeclaration'.
10     static ɵmod: i0.ɵɵNgModuleDeclaration<NgxFileDragDropModule, [typeof i1.NgxFileDragDropComponent, typeof i2.BytePipe], [typeof i3.CommonModule, typeof i4.MatChipsModule, typeof i5.MatIconModule, typeof i6.MatTooltipModule], [typeof i1.NgxFileDragDropComponent, typeof i2.BytePipe]>;
                       ~~~~~~~~~~~~~~~~~~~~~
node_modules/ngx-file-drag-drop/lib/ngx-file-drag-drop.module.d.ts:11:21 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/new-client/node_modules/@angular/core/core"' has no exported member 'ɵɵInjectorDeclaration'.
11     static ɵinj: i0.ɵɵInjectorDeclaration<NgxFileDragDropModule>;
                       ~~~~~~~~~~~~~~~~~~~~~
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@1.0.1 build: `ng build --prod --build-optimizer=false`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the client@1.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-12-14T17_41_21_825Z-debug.log

【问题讨论】:

你查看ngx-file-drag-drop的版本了吗?看来这个库需要比你当前使用的更高的 Angular 版本 版本号是ngx-file-drag-drop": "^5.1.0,之前还好我什么都没改。 检查已安装的版本,因为 ^ 表示每个兼容版本都可以被 npm 使用/安装,所以可能你安装了更新的版本导致这个错误 你可以在node_modules/ngx-file-drag-dropnpm list ngx-file-drag-drop的package.json中看到 版本是5.1.3 所以是不同的。我该怎么办? 【参考方案1】:

解决方案是从 package.json 中的 ngx-drag-drop 库中删除 ^ 字符,因为我有 "ngx-file-drag-drop": "^5.1.0" 所以安装的版本是 5.1.3 而不是 5.1.0。要获取有关角色^ 的更多信息,请参阅What's the difference between tilde(~) and caret(^) in package.json?

【讨论】:

以上是关于为啥@angular/core/core 没有导出成员'ɵɵFactoryDe​​claration'。构建项目时抛出错误?的主要内容,如果未能解决你的问题,请参考以下文章

halcon导出的代码为啥没有runhalcon

为啥在尝试升级 Angular 时出现“没有导出成员”错误?

为啥我的搅拌机 .fbx 文件没有导出到 Unity?

为啥有的dll里没有导出函数?

为啥在另一个 Typescript 项目中导入时没有得到导出的对象?

sqlyog怎么把数据库导出csv为啥表头没有输入