Tuesday, January 11, 2022

node.js: angular: An unhandled exception occurred: require() of ES Module node_modules/@angular/compiler-cli/bundles/index.js


 >PROBLEM


- After the following procedure:


ng new myproject

npm install rxjs

npm audit fix --force

ng serve


- The angular application fails to start returning the following message:


An unhandled exception occurred: require() of ES Module node_modules/@angular/compiler-cli/bundles/index.js 

/data/prj/node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js not supported. 

Instead change the require of index.js in 

/data/prj/node_modules/@angular-devkit/build-angular/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js to a dynamic 

import() which is available in all CommonJS modules. 

See "/tmp/ng-Fe4Op7/angular-errors.log" for further details. 





>SOLUTION


Avoid using --force argument with "npm audit" with this versions (detailed below under ENV topic) until the bug is fixed.

Use just: 

npm audit fix


>ENV

Windows 10

Angular CLI: 13.1.2

Node: 16.13.1

Package Manager: npm 8.1.2

OS: win32 x64


No comments:

Post a Comment

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...