Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build Angular 4 example with Webpack

I recently installed Angular 4 (RC2) and copied the files from the simple Quickstart example. But when I try to build the project with Webpack, I get errors stating that Rxjs can't be resolved:

WARNING in ~/@angular/core/@angular/core.es5.js
6857:19-40 Critical dependency: the request of a dependency is an expression

WARNING in ~/@angular/core/@angular/core.es5.js
6883:19-106 Critical dependency: the request of a dependency is an expression

ERROR in ~/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/Subject' in 'node_modules/@angular/core/@angular'
 @ ~/@angular/core/@angular/core.es5.js 26:0-39
 @ ./app/app.module.ts
 @ ./main.ts

ERROR in ~/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/observable/merge' in 'node_modules/@angular/core/@angular'
 @ ~/@angular/core/@angular/core.es5.js 23:0-46
 @ ./app/app.module.ts
 @ ./main.ts

ERROR in ~/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/operator/share' in 'node_modules/@angular/core/@angular'
 @ ~/@angular/core/@angular/core.es5.js 24:0-44
 @ ./app/app.module.ts
 @ ./main.ts

ERROR in ~/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/symbol/observable' in 'node_modules/@angular/core/@angular'
 @ ~/@angular/core/@angular/core.es5.js 25:0-54
 @ ./app/app.module.ts
 @ ./main.ts

ERROR in ~/@angular/core/@angular/core.es5.js
Module not found: Error: Can't resolve 'rxjs/Observable' in 'node_modules/@angular/core/@angular'
 @ ~/@angular/core/@angular/core.es5.js 22:0-45
 @ ./app/app.module.ts
 @ ./main.ts

I've installed Rxjs 5.0.1, which I think is the version that Angular is expecting. I can't think of anything else to do.

like image 377
MatthewScarpino Avatar asked Mar 02 '17 14:03

MatthewScarpino


People also ask

Can I use webpack with Angular?

The Angular build process uses webpack behind the scenes to transpile TypeScript to JavaScript, transform Sass files to CSS, and many other tasks. To understand the importance of this build tool, it helps to understand why it exists.

Does ng build use webpack?

The application builder uses the webpack build tool, with default configuration options specified in the workspace configuration file ( angular.json ) or with a named alternative configuration.

Does Angularjs support webpack 5?

Webpack 5 SupportYes you can use webpack 5 with Angular 11, but there are 2 things you need to keep in mind: This can be used if you are using yarn.

What is the difference between Angular CLI and webpack?

Webpack is a module bundler and task runner. Angular CLI is a command line interface that bundles some of the techniques mentioned above. Under the hood it uses Webpack. It is easy to create an application that works out of the box.


1 Answers

new ContextReplacementPlugin( /angular(\\|\/)core(\\|\/)@angular/, path.resolve(__dirname, '../src') ) Works for me for webpack in webpack.common.js

like image 107
AniketGole Avatar answered Sep 23 '22 02:09

AniketGole