0

I have this message when I try to create a component using CLI: An unhandled exception occurred: Must use import to load ES Module: C:...\node_modules@angular\compiler\fesm2015\compiler.mjs I use Angular 14 (I migrate my project this last time from 12 to 14):

Angular CLI: 14.2.1
Node: 14.17.3
Package Manager: npm 8.11.0
OS: win32 x64

Angular: 14.2.0
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1303.9
@angular-devkit/build-angular      14.2.1
@angular-devkit/core               13.3.9
@angular-devkit/schematics         14.2.1
@angular/cdk                       14.1.3
@angular/cli                       14.2.1
@angular/material                  14.1.3
@angular/material-moment-adapter   14.1.3
@schematics/angular                14.2.1
rxjs                               7.5.6
typescript                         4.6.4

Do you have any idea about this. thank you.

Abdel
  • 63
  • 3
  • Random stab in the dark, but have you updated your node? If that doesn't work, what happens if you remove your package-lock.json and try building it from scratch? – SomeStudent Sep 09 '22 at 17:04
  • update your node version. This is potentially a replicate of this post: https://stackoverflow.com/questions/61670459/importing-in-node-js-error-must-use-import-to-load-es-module – onrails Sep 09 '22 at 20:00
  • You can find solutions for the above error message there – onrails Sep 09 '22 at 20:01
  • I use the version V14.17.3, I add the "type":"module" in the package file and the error still here we I rey to use the CLI (try to create a component for example), but the build (ng serve) work well. Any idea please ? thank yo – Abdel Sep 12 '22 at 13:58

0 Answers0