Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Cannot resolve type entity i4.FocusTrapModule to symbol #6662

Closed
vignesh-s opened this issue Jul 5, 2024 · 14 comments
Closed

Error: Cannot resolve type entity i4.FocusTrapModule to symbol #6662

vignesh-s opened this issue Jul 5, 2024 · 14 comments
Assignees

Comments

@vignesh-s
Copy link

vignesh-s commented Jul 5, 2024

importing ModalModule.forRoot() gives the below error on starting the server in angular 18

✘ [ERROR] Angular compilation initialization failed. [plugin angular-compiler]

  Error: Cannot resolve type entity i4.FocusTrapModule to symbol

Versions of ngx-bootstrap, Angular, and Bootstrap:

"@angular/core": "^18.0.6",
"bootstrap": "^5.3.3",
"ngx-bootstrap": "^18.0.0",

Build system: Angular CLI

Expected behavior

Server should start without any error

@lexasq
Copy link
Contributor

lexasq commented Jul 5, 2024

Hi @vignesh-s could you please provide plunker sample for better verification in the meantime what have you tried to add @angular/cdk to the project?

@vignesh-s
Copy link
Author

Yes, I am having @angular/cdk version same as angular core

@evil-o
Copy link

evil-o commented Jul 8, 2024

I'm facing the same issue, and I created a repository that reproduces the issue for me. You can find it here: https://github.com/evil-o/ngx-bootstrap-6662-repro.

The repository should be minimal, I created an Angular app with ng new (npm start works) and added an import of ngx-bootstrap (npm start shows the error in the original bug report).

@lexasq
Copy link
Contributor

lexasq commented Jul 8, 2024

Thanks, that helps a lot!

@PShonda
Copy link

PShonda commented Jul 9, 2024

Replying for you @vignesh-s , @evil-o
Hello, I am getting this error message as well. And I have some quick fix ideas ahead of time to keep working on to share.

In my situation error because "ngx-bootstrap/focus-trap"

  1. I would like to use ngx-bootstrap/modal .
  2. On setup state i will should to add "ModalModule.forRoot()" in import [] at app module or in related
  3. Then i will run serve to review result it have a problem now .

My environment is Windows 11 Pro and use NVM for manage version of node .

How i Fix

  1. Run npm install any dependecy
  2. Goto node_modules/ngx-bootstrap/<your_component_call>/.module.d.ts (your component mean what module if you want to call and '' is same meaing)
  3. Replace import path from "ngx-bootstrap/focus-trap" to "./../focus-trap/focus-trap.module"
  4. Then restart serve or re-build .

I think import route are not work because if i try to click link ("ngx-bootstrap/focus-trap" ) they will route to path ("ngx-bootstrap/focus-trap/fesm2022/ngx-bootstrap-modal.mjs") and broken

PS. if you have many people in project i will recommend create script for replace and set it in postinstall at package.json between wait fix patch

CC. @lexasq my info can help you for clear it ?

@lexasq
Copy link
Contributor

lexasq commented Jul 9, 2024

@vignesh-s @evil-o @PShonda thank you all on the intel. So far I think I found the issue, could you please try it as well. In your tsconfig.json
"compilerOptions": { ... "moduleResolution": "node", ... }

Does work on @evil-o sample. I also found your solution as well @PShonda , unfortunatelly this is definitely not a lasting one.

@PShonda
Copy link

PShonda commented Jul 9, 2024

@lexasq I'm worried too. Thank you very much for the suggestion.
Update config in tsconfig.json it so better

@lexasq lexasq self-assigned this Jul 9, 2024
@evil-o
Copy link

evil-o commented Jul 10, 2024

@lexasq , that actually resolves the issue for me, both in the minimal sample and my actual application!

I assume this is a workaround? Bundler module resolution, in my opinion is more appropriate for an angular application, and it's also the default setting that the Angular CLI generates.

In any case, for now, this fixes my issue, so thanks for the quick response!

@lexasq lexasq closed this as completed Jul 11, 2024
@slubowsky
Copy link

@lexasq Just BTW - this actually prevents using some libraries without nasty workarounds. See for example benjamine/jsondiffpatch#356 (comment)

@lexasq
Copy link
Contributor

lexasq commented Jul 15, 2024

@slubowsky you are right, it's very unfortunate, but whole library builds as node now, so that is the best solution we could offer right now. We're restarting our opensource contributions, and chances are we'll get to this issue as well.

@salartaimoor10
Copy link

salartaimoor10 commented Jul 16, 2024

I changed the all FocusTrapModule imports to ngx-bootstrap/focus-trap.module but still facing this issue.
error

@salartaimoor10
Copy link

Replying for you @vignesh-s , @evil-o Hello, I am getting this error message as well. And I have some quick fix ideas ahead of time to keep working on to share.

In my situation error because "ngx-bootstrap/focus-trap"

  1. I would like to use ngx-bootstrap/modal .
  2. On setup state i will should to add "ModalModule.forRoot()" in import [] at app module or in related
  3. Then i will run serve to review result it have a problem now .

My environment is Windows 11 Pro and use NVM for manage version of node .

How i Fix

  1. Run npm install any dependecy
  2. Goto node_modules/ngx-bootstrap/<your_component_call>/.module.d.ts (your component mean what module if you want to call and '' is same meaing)
  3. Replace import path from "ngx-bootstrap/focus-trap" to "./../focus-trap/focus-trap.module"
  4. Then restart serve or re-build .

I think import route are not work because if i try to click link ("ngx-bootstrap/focus-trap" ) they will route to path ("ngx-bootstrap/focus-trap/fesm2022/ngx-bootstrap-modal.mjs") and broken

PS. if you have many people in project i will recommend create script for replace and set it in postinstall at package.json between wait fix patch

CC. @lexasq my info can help you for clear it ?

I changed all FocusTrapModule imports to ngx-bootstrap/focus-trap.module but still facing this issue.
error

@lexasq
Copy link
Contributor

lexasq commented Jul 17, 2024

@vignesh-s @evil-o @PShonda thank you all on the intel. So far I think I found the issue, could you please try it as well. In your tsconfig.json "compilerOptions": { ... "moduleResolution": "node", ... }

Does work on @evil-o sample. I also found your solution as well @PShonda , unfortunatelly this is definitely not a lasting one.

@salartaimoor10 this is the answer

@salartaimoor10
Copy link

@vignesh-s @evil-o @PShonda thank you all on the intel. So far I think I found the issue, could you please try it as well. In your tsconfig.json "compilerOptions": { ... "moduleResolution": "node", ... }
Does work on @evil-o sample. I also found your solution as well @PShonda , unfortunatelly this is definitely not a lasting one.

@salartaimoor10 this is the answer

@lexasq Thankyou, now it is working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants