Unable to build Angular 4 example using Webpack

I recently installed Angular 4 (RC2) and copied the files from a simple quick start example . But when I try to build a project using Webpack, I get errors stating that Rxjs cannot 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 installed Rxjs 5.0.1, which I think is the version expected by Angular. I can't think of anything else.

+5
source share
2 answers

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

+7
source

work without problems in this configuration:

 new webpack.ContextReplacementPlugin( /angular(\\|\/)core(\\|\/)@angular/,/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, helpers.root('../src'), {} ), 

make sure there are two points on helpers.root, not one. ('../SRC')

0
source

Source: https://habr.com/ru/post/1264942/


All Articles