Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When updating to Angular 5 I'm getting error: Critical dependency: the request of a dependency is an expression

Previously my app was working with Angular 4.4.6. I followed the guide https://angular-update-guide.firebaseapp.com/ to update to Angular 5. I used this:

npm install @angular/animations@'^5.0.0' @angular/common@'^5.0.0' @angular/compiler@'^5.0.0' @angular/compiler-cli@'^5.0.0' @angular/core@'^5.0.0' @angular/forms@'^5.0.0' @angular/http@'^5.0.0' @angular/platform-browser@'^5.0.0' @angular/platform-browser-dynamic@'^5.0.0' @angular/platform-server@'^5.0.0' @angular/router@'^5.0.0' [email protected] rxjs@'^5.5.2'

But it didn't work. It would give me an error no valid target found for rxjs. So instead, I simply changed the versions in my package.json and ran npm install and it worked, but when running npm start, I get the error

WARNING in ./~/@angular/core/esm5/core.js
6456:15-102 Critical dependency: the request of a dependency is an expression

So I deleted my node_modules and did npm install once again, and I still get the same error when running npm start.

Screenshot:Screenshot

like image 902
Christian Avatar asked Nov 04 '17 19:11

Christian


1 Answers

I managed to solve it by changing the webpack.common.js with this:

new webpack.ContextReplacementPlugin(
    /(.+)?angular(\\|\/)core(.+)?/,
    root('./src'),
    {}
)
like image 170
Christian Avatar answered Sep 19 '22 11:09

Christian