简体   繁体   English

Ng serve throwing @angular/core/core 没有导出成员'eeFactoryDef'

[英]Ng serve throwing @angular/core/core has no exported member 'eeFactoryDef'

Im getting like 50 errors that all say that angular/core/core has no exported member 'eeFactoryDef'.我收到大约 50 个错误,都说 angular/core/core 没有导出成员 'eeFactoryDef'。

They come from different node_modules, for example angular/cdk, ng-bootstrap, ngx-pipes, ng2-dragula and some more.它们来自不同的 node_modules,例如 angular/cdk、ng-bootstrap、ngx-pipes、ng2-dragula 等等。 I didn't find anything from google either.我也没有从谷歌找到任何东西。

../node_modules/@angular/cdk/drag-drop/typings/directives/drag-handle.d.ts:23:33 - error TS2694: Namespace '"/Users/heikopiirme/Documents/realNewClient/client/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDef'.

23     static ngFactoryDef: ɵngcc0.ɵɵFactoryDef<CdkDragHandle>;

This is my package.json file:这是我的 package.json 文件:

Here are my depencencies:这是我的依赖项:

    "@angular-skyhook/core": "^1.1.1",
    "@angular-skyhook/multi-backend": "^1.1.1",
    "@angular/animations": "^8.2.6",
    "@angular/cdk": "^8.2.0",
    "@angular/common": "^8.2.6",
    "@angular/compiler": "^8.2.6",
    "@angular/core": "^8.2.6",
    "@angular/forms": "^8.2.6",
    "@angular/http": "^7.1.4",
    "@angular/material": "^8.2.0",
    "@angular/platform-browser": "^8.2.6",
    "@angular/platform-browser-dynamic": "^8.2.6",
    "@angular/router": "^8.2.6",
    "@ng-bootstrap/ng-bootstrap": "^5.1.1",
    "@ng-select/ng-select": "^3.0.7",
    "@swimlane/ngx-datatable": "^13.1.0",
    "@types/googlemaps": "^3.36.5",
    "angular2-draggable": "^2.3.1",
    "bootstrap": "^4.2.1",
    "core-js": "^2.6.1",
    "drag-drop-webkit-mobile": "^1.4.1",
    "exif-js": "^2.3.0",
    "hammerjs": "^2.0.8",
    "mobile-drag-drop": "^2.3.0-rc.2",
    "moment": "^2.24.0",
    "moment-range": "^4.0.2",
    "net": "^1.0.2",
    "ng2-dnd": "^5.0.2",
    "ng2-dragula": "^2.1.1",
    "ng2-file-upload": "^1.3.0",
    "ng2-img-max": "^2.1.18",
    "ngx-bar-rating": "^1.1.0",
    "ngx-bootstrap": "^4.3.0",
    "ngx-material-timepicker": "^5.1.0",
    "ngx-permissions": "^5.0.0",
    "ngx-pipes": "2.5.6",
    "ngx-toastr": "^10.0.4",
    "react-dnd-html5-backend": "^7.6.0",
    "rxjs": "^6.5.3",
    "sockjs-client": "^1.3.0",
    "stompjs": "^2.3.3",
    "touchscreen-dnd-shim": "^1.2.2",
    "underscore": "^1.9.1",
    "zone.js": "~0.9.1"

And here are my dev dependencies:这是我的开发依赖项:

"@angular-devkit/build-angular": "^0.803.4",
    "@angular/cli": "~8.3.4",
    "@angular/compiler-cli": "^8.2.6",
    "@angular/language-service": "^8.2.6",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^8.9.5",
    "codelyzer": "~5.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "node-sass": "^4.12.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.5.3"
  }

Couldn't find any information on google for some reason.由于某种原因无法在谷歌上找到任何信息。

I ran into this after updating some packages (including Angular from 8 to 9), then downgrading again.我在更新一些软件包(包括从 8 到 9 的 Angular)后遇到了这个问题,然后再次降级。

The solution was to nuke the node_modules folder and then do a fresh npm install.解决方案是node_modules文件夹,然后重新安装 npm。

A lot of people saying the solution here is to simply "delete your node_modules".很多人说这里的解决方案是简单地“删除你的 node_modules”。 This may or may not work .这可能有效也可能无效


To understand why that is the case, you need to understand why you're getting this error.要理解为什么会这样,您需要理解为什么会收到此错误。 This is caused by a breaking change in Angular where code generated using angular version x is not compatible with angular version y (happens in multiple versions, I'm currently getting it between 10 and 13).这是由Angular 中的重大更改引起的,其中使用 angular 版本 x 生成的代码与 angular 版本 y 不兼容(发生在多个版本中,我目前在 10 到 13 之间)。 The eeFactoryDef is a method generated by Angular when your source is compiled. eeFactoryDef是编译源代码时由 Angular 生成的方法。 The name of this method has changed over the years.这种方法的名称多年来一直在变化。 So the delete node_modules works because it's assuming that you've just upgraded angular and you have an old version still hanging about.所以删除 node_modules 是有效的,因为它假设你刚刚升级了 angular 并且你有一个旧版本仍然存在。

This also explains why there are so many different answers to this question.这也解释了为什么这个问题会有这么多不同的答案。 The angular incompatibility could be in your code or one of its dependancies. angular 不兼容可能在您的代码或其依赖项之一中。 All the people saying "I get this in x library" are basically because of this underlying problem.所有说“我在 x 库中得到这个”的人基本上都是因为这个潜在的问题。


But , you can also get this issue if you have a dependency issue.但是,如果你有依赖性问题,你也会遇到这个问题。 The easiest way to diagnose this problem is to run npm ls @angular/core .诊断此问题的最简单方法是运行npm ls @angular/core This will list all the library dependencies that link to this lib, for example I get:这将列出链接到该库的所有库依赖项,例如我得到:

`-- UNMET PEER DEPENDENCY @angular/core@13.2.5

npm ERR! peer dep missing: @angular/core@~11.2.13, required by blah@2.1.1
npm ERR! peer dep missing: @angular/core@12.2.15, required by blah@13.0.4
npm ERR! peer dep missing: @angular/core@^11.0.5, required by blah@11.0.5
npm ERR! peer dep missing: @angular/core@^6.0.0 || ^7.0.0 || ^8.0.0, required by ngx-avatar@3.7.0

In this scenario you need to upgrade the conflicting libraries so that they all use the same (or a compatible) version of angular ( and no amount of deleting and re-adding of node_modules will make any difference ).在这种情况下,您需要升级冲突的库,以便它们都使用相同(或兼容)的 angular 版本(并且删除和重新添加 node_modules 不会有任何不同)。


Another problem that has this as a symptom is the Ivy compiler .另一个以此为征兆的问题是Ivy 编译器 Again, this can produce an incompatible build between libraries and applications.同样,这会在库和应用程序之间产生不兼容的构建。 The solution here depends on where the incompatibility lies.这里的解决方案取决于不兼容的地方。 If you lib is not Ivy but your application is, then you can either opt out of Ivy ( note this is now disabled in Angular 12 )如果你的 lib 不是 Ivy 但你的应用程序是,那么你可以选择退出 Ivy注意这现在在 Angular 12 中被禁用

tsconfig.json tsconfig.json

{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": []
  },
  "files": [
    "src/main.ts",
    "src/polyfills.ts"
  ],
  "include": [
    "src/**/*.d.ts"
  ],
  "angularCompilerOptions": {
    "enableIvy": false
  }
}

Or run ngcc in a postinstall event:或者在安装后事件中运行ngcc

package.json package.json

{
   "scripts": {
       "postinstall": "ngcc"
   }
}

I'm getting the same error.我遇到了同样的错误。 I'm using Angular 9.7.1, I first tried to delete the node_modules and npm install but it didn't work so I finally fixed it adding this to the tsconfig.json:我正在使用 Angular 9.7.1,我首先尝试删除 node_modules 和 npm 安装,但它没有工作,所以我最终修复它添加到 tsconfig.Z466DEEC76ECDF5FCA6D38571F6324:

"compilerOptions":{
 [...]
 "paths": {
      "@angular/*": ["./node_modules/@angular/*"]
    }
}

I got the issue when switching between Angular 8 and 9 multiple times as mentioned by peregrination .peregrination所述,我在 Angular 8 和 9 之间多次切换时遇到了问题。

Solution for me was not to delete "node_module" and run "npm install" again, but to remove and re-install npm packages to angular 8 compatible version which were mentioned in the error.我的解决方案不是删除“node_module”并再次运行“npm install”,而是删除并重新安装 npm 包到错误中提到的 angular 8 兼容版本。

ERROR in node_modules/ngx-infinite-scroll/src/modules/infinite-scroll.directive.d.ts:27:25 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDef'.
27     static ɵfac: ɵngcc0.ɵɵFactoryDef<InfiniteScrollDirective, never>;
                           ~~~~~~~~~~~~
node_modules/ng-click-outside/lib_commonjs/click-outside.directive.d.ts:34:25 - error TS2694: Namespace '"/opt/atlassian/pipelines/agent/build/node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDef'.
34     static ɵfac: ɵngcc0.ɵɵFactoryDef<ClickOutsideDirective, never>;

I run ino the same issue when trying to upgrade to Angular 10 in another feature branch.尝试在另一个功能分支中升级到 Angular 10 时,我遇到了同样的问题。

it messed up 'node_modules' folder.它弄乱了“node_modules”文件夹。

Solution:解决方案:

run npm ci .运行npm ci

Delete folder node_modules then run the npm i command删除文件夹node_modules然后运行npm i命令

In addition to the reasons/solutions previously shared, another reason this could happen is if npm packages are incompatible with your current Angular version.除了之前分享的原因/解决方案之外,可能发生这种情况的另一个原因是 npm 软件包与您当前的 Angular 版本不兼容。

For example, I got these after running npm i primeng .例如,我在运行npm i primeng后得到了这些。 NPM installed the most recent version (v12), but I was only running ng11. NPM 安装了最新版本(v12),但我只运行 ng11。

In my case, the solution was to upgrade Angular, but another solution would be to downgrade the npm package.就我而言,解决方案是升级 Angular,但另一种解决方案是降级 npm package。

I was recently having similar issue with ng-lazyload-image plugin.我最近在使用ng-lazyload-image插件时遇到了类似的问题。

We were using Angular 9 and in our package.json we were calling "ng-lazyload-image": "^9.1.0"我们使用的是 Angular 9,在我们的 package.json 中我们调用了"ng-lazyload-image": "^9.1.0"

I changed it to "ng-lazyload-image": "9.1.0" and the build started to work in Jenkins.我将其更改为"ng-lazyload-image": "9.1.0"并且构建在 Jenkins 开始运行。

Posting it here to help someone, facing the same issue with this plugin.将其张贴在这里以帮助遇到此插件同样问题的人。

I am seeing the same issue mentioned above using angular/cli@8.3.19我使用 angular/cli@8.3.19 看到了上面提到的相同问题

Tried the following as mentioned in the comments above.如上面评论中所述,尝试了以下操作。

  1. Delete '/node_modules'删除'/node_modules'

(assuming from project and not under …/Roaming/npm/node_modules) (假设来自项目而不是…/Roaming/npm/node_modules)

  1. Run 'npm install'运行“npm 安装”

But the error still persists after running 'ng serve".'但运行“ng serve”后错误仍然存在。

I tried clearing cache and update angular/cli with no result.我尝试清除缓存并更新 angular/cli 没有结果。

Any other suggestions?还有其他建议吗?

Main project had Angular 8 and I got this issue when some packages with Angular 9 were installed.主要项目有 Angular 8 ,当安装了一些带有 Angular 9 的软件包时,我遇到了这个问题。 Use this for upgrade steps: https://update.angular.io - specifically upgrade to latest version of 8 ng update @angular/core@8 @angular/cli@8 then to 9 ng update @angular/core@9 @angular/cli@9 .将其用于升级步骤: https://update.angular.io - 特别升级到最新版本的 8 8 ng update @angular/core@8 @angular/cli@8 ng update @angular/core@9 @angular/cli@9

I deleted the node_module folder and then gave npm install .我删除了node_module文件夹,然后给了npm install I landed up on the same error again.我再次遇到同样的错误。

Downgrading the version of the npm package that I used helped me with this error.降级我使用的 npm package 的版本帮助我解决了这个错误。 Need not remove all the files in the不需要删除所有文件

node_modules节点模块

folder.文件夹。

Note that this might be a compatibility issue with one of your libraries.请注意,这可能是与您的某个库的兼容性问题。 Eg: the library expects you to have Angular 12, but your project runs Angular 11 instead.例如:库希望您拥有 Angular 12,但您的项目运行的是 Angular 11。 Take a look at the library's package.json history and check if it is using a greater Angular version indeed.查看库的package.json历史记录并检查它是否确实使用了更大的 Angular 版本。 If it is, then you'll have two options:如果是,那么您将有两个选择:

  1. Upgrade your Angular version to be the same as the library's将您的 Angular 版本升级为与库的相同
  2. Downgrade the library version back to when it used the same Angular version as yours (might not be possible if the library never used that Angular version)将库版本降级回使用与您相同的 Angular 版本时(如果库从未使用过该 Angular 版本,则可能无法实现)

This error can happen if you have a project using Angular 12, that depends on a library built prior to Angular 12.如果您有一个使用 Angular 12 的项目,则可能会发生此错误,这取决于在 Angular 12 之前构建的库。

You will have to have the library catch up to Angular 12 to resolve the issue.您必须让库赶上 Angular 12 才能解决问题。

Solved it by upgrading angular from v11 to v12 with guidance from the angular upgrade documentation在 angular 升级文档的指导下,通过将 angular 从 v11 升级到 v12 解决了这个问题

ng update @angular/cli @angular/core --allow-dirty ng update @angular/cli @angular/core --allow-dirty

it works for me.这个对我有用。

I hit this issue today after updating project to Angular 12 on feature branch then switching branch back to main which was still Angular 10. In addition I noticed the error Another process, with id 95467, is currently running ngcc.我今天在功能分支上将项目更新为 Angular 12 然后将分支切换回仍然是 Angular 10 的主分支后遇到了这个问题。此外,我注意到错误Another process, with id 95467, is currently running ngcc. which proceeded the x was not found in @angular/core errors. x was not found in @angular/core But I didn't have any other install / build / serve tasks running.但是我没有运行任何其他安装/构建/服务任务。

After running the following commands this issue was fixed:运行以下命令后,此问题已修复:

npm ci
ng update

Suggestion was to update @angular/core and @angular/cli from 12.2.9 -> 12.2.10 so I ran:建议是从 12.2.9 -> 12.2.10 更新@angular/core@angular/cli所以我跑了:

ng update @angular/core @angular/cli

Then was able to run npm start to run Angular 12 app ok然后能够运行npm start运行 Angular 12 app ok

This issue also comes up when we install a libraray to our project and the fix for it is, must check the version compatibility of the library with the angular version you have.当我们将库安装到我们的项目时也会出现此问题,修复它必须检查库与您拥有的 angular 版本的版本兼容性。

In my case, it was being caused by ngx-toastr.就我而言,它是由 ngx-toastr 引起的。 After much of hit and trial, solved using below approach:经过大量的尝试和尝试,使用以下方法解决了:

  1. First checked the version of angular using command ng version.首先使用命令 ng version 检查 angular 的版本。
  2. Visited https://www.npmjs.com/package/ngx-toastr and check the toastr version suitable for my angular version.访问https://www.npmjs.com/package/ngx-toastr并检查适合我的 angular 版本的 toastr 版本。
  3. Installed the suitable version of toastr.安装了合适版本的 toastr。

I faced the same problem when I was trying to integrate ngx-mask package.当我尝试集成 ngx-mask package 时,我遇到了同样的问题。

Reason For Issue: angular version was 9.0.1 and ngx-mask version was higher问题原因: angular 版本为 9.0.1,ngx-mask 版本更高

Solution: I downgraded the ngx-mask version to 9.0.1 which was compatible with my angular version解决方案:我将 ngx-mask 版本降级到与我的 angular 版本兼容的 9.0.1

Quick solution - check the Angular version in your package.json, then make sure that the Angular CLI matching version is installed globally to NPM.快速解决方案 - 检查 package.json 中的 Angular 版本,然后确保 Angular CLI 匹配版本已全局安装到 NPM。

Eg if you have Angular 10.2.4 installed in your project, make sure to also add that specific Angular CLI globally by doing:例如,如果您的项目中安装了 Angular 10.2.4,请确保还通过执行以下操作在全局范围内添加该特定的 Angular CLI:

npm install -g @angular/cli@10.2.4

I installed ngx-indexed-db and I was having this error Ng serve throwing @angular/core/core has no exported member for me it was purely a version based error I solved it by downgrading the library using this command我安装了ngx-indexed-db并且我遇到了这个错误Ng serve throwing @angular/core/core has no exported member for me 这纯粹是一个基于版本的错误我通过使用这个命令降级库解决了它

npm i ngx-indexed-db@9.1.0 npm 我 ngx-indexed-db@9.1.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 @ angular / core / index“&#39;没有导出的成员&#39;Version&#39; - @angular/core/index"' has no exported member 'Version' @angular/core/testing 没有导出成员“MockApplicationRef” - @angular/core/testing has no exported member 'MockApplicationRef' 模块 '"@angular/core"' 没有导出的成员 'ReactiveFormsModule' - Module '"@angular/core"' has no exported member 'ReactiveFormsModule' Angular 7:@ angular / core / core没有导出成员&#39;OpaqueToken&#39; - Angular 7:@angular/core/core has no exported member 'OpaqueToken' node_modules/@angular/core/core"' 没有导出成员 'ɵɵFactoryDeclaration' - node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration' 为什么@angular/core/core 没有导出成员'ɵɵFactoryDeclaration'。 使用 angular cdk 虚拟滚动条时抛出的错误 - Why is @angular/core/core has no exported member 'ɵɵFactoryDeclaration'. error thrown when using angular cdk virtual scroller 获取 /node_modules/@angular/core/core 在 Angular8 中没有导出成员 ɵɵFactoryDef - Getting /node_modules/@angular/core/core has no exported member ɵɵFactoryDef in Angular8 node_modules/ng2-toastr/src/toast-container.component.d.ts(1,48) 中的错误:TS2305-/node_modules/@angular/core/core"' 没有导出成员 - ERROR in node_modules/ng2-toastr/src/toast-container.component.d.ts(1,48): TS2305- /node_modules/@angular/core/core"' has no exported member 将 Swiper 导入 Angular 会导致错误 - @angular/core/core&quot;&#39; 没有导出成员 &#39;ɵɵFactoryDe​​claration&#39; - Import Swiper into Angular causes error - @angular/core/core"' has no exported member 'ɵɵFactoryDeclaration' 这个错误是什么意思 --&gt;node_modules/@angular/core/core&quot;&#39; has no export member &#39;ɵɵFactoryDe​​claration&#39; - What does this error mean -->node_modules/@angular/core/core"' has no exported member 'ɵɵFactoryDeclaration'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM