UnhandledPromiseRejectionWarning: Error: Symbol 'module' declared in 'path' is not exported from 'package'

Viewed 163

In my Angular 11 project, I am getting the following error when building and serving the project.

(node:15218) UnhandledPromiseRejectionWarning: Error: Symbol LanguageTranslationModule declared in path/Y/node_modules/@abc/X/lib/language-translations.d.ts is not exported from @abc/X (import into path/Y/src/lib/.module.ts) .......

Error: ./src/main.ts Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js): Error: Symbol LanguageTranslationModule declared in path/Y/node_modules/@abc/X/lib/language-translations.d.ts is not exported from @abc/X (import into path/Y/src/lib/.module.ts) .......

Error: ./src/polyfills.ts Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js): Error: Symbol LanguageTranslationModule declared in path/Y/node_modules/@abc/X/lib/language-translations.d.ts is not exported from @abc/X (import into path/Y/src/lib/.module.ts) .......

Scenario: I want to use a library(X) as a dependency inside another library(Y). When I install all the packages and dependent packages(including X's) in Y library, it gives the above error.

Deleting node modules etc and reinstalling them didn't work for me.

Please suggest a method to solve this.

Versions:

Angular CLI: 11.1.4
Node: 10.16.0
OS: linux x64

Angular: 11.1.0

sample package.json of X library:

{
  "name": "@abc/X",
  "version": "0.0.2",
  "peerDependencies": {
    "@angular/common": "^11.1.2",
    "@angular/core": "^11.1.2"
  },
  "dependencies": {
    "tslib": "^2.0.0",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0"
  },
  "publishConfig": {
    "registry": "xyz"
  }
}

sample package.json of Y library:

{
  "name": "@abc/Y",
  "version": "0.0.5",
  "peerDependencies": {
    "@angular/common": "^11.1.0",
    "@angular/core": "^11.1.0"
  },
  "dependencies": {
    "tslib": "^2.0.0",
    "@abc/X": "0.0.2"
  },
  "publishConfig": {
    "registry": "xyz"
  }
} 

sample Y.module.ts:

import { NgModule } from '@angular/core';
import { YComponent } from './Y.component';
import { CommonModule } from '@angular/common';
import { LanguageTranslationModule } from '@abc/X';



@NgModule({
  declarations: [YComponent],
  imports: [
    CommonModule,
    LanguageTranslationModule
  ],
  exports: [YComponent]
})
export class YModule { }
0 Answers
Related