When updating to Angular 5 I'm getting error: Critical dependency: the request of a dependency is an expression
When updating to Angular 5 I'm getting error: Critical dependency: the request of a dependency is an expression
之前我的应用程序使用 Angular 4.4.6。我关注了 guide
https://angular-update-guide.firebaseapp.com/ 更新到 Angular 5. 我用过这个:
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' typescript@2.4.2 rxjs@'^5.5.2'
但是没有用。它会给我一个错误 no valid target found for rxjs
。因此,我只是简单地更改了 package.json 和 运行 npm install
中的版本并且它起作用了,但是当 运行 npm start 时,我得到了错误
WARNING in ./~/@angular/core/esm5/core.js
6456:15-102 Critical dependency: the request of a dependency is an expression
所以我删除了我的 node_modules 并再次安装了 npm,当 运行 npm start 时我仍然得到同样的错误。
截图:
我设法通过更改 webpack.common.js 解决了这个问题:
new webpack.ContextReplacementPlugin(
/(.+)?angular(\|\/)core(.+)?/,
root('./src'),
{}
)
之前我的应用程序使用 Angular 4.4.6。我关注了 guide https://angular-update-guide.firebaseapp.com/ 更新到 Angular 5. 我用过这个:
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' typescript@2.4.2 rxjs@'^5.5.2'
但是没有用。它会给我一个错误 no valid target found for rxjs
。因此,我只是简单地更改了 package.json 和 运行 npm install
中的版本并且它起作用了,但是当 运行 npm start 时,我得到了错误
WARNING in ./~/@angular/core/esm5/core.js
6456:15-102 Critical dependency: the request of a dependency is an expression
所以我删除了我的 node_modules 并再次安装了 npm,当 运行 npm start 时我仍然得到同样的错误。
截图:
我设法通过更改 webpack.common.js 解决了这个问题:
new webpack.ContextReplacementPlugin(
/(.+)?angular(\|\/)core(.+)?/,
root('./src'),
{}
)