我最近安装了Angular 4 (RC2),并从简单的Quickstart example复制了文件。但是当我尝试和Webpack一起构建这个项目时,我得到的错误信息是Rxjs无法解决:
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
我已经安装了Rxjs 5.0.1,我认为这就是Angular所期望的版本。我想不出还能做什么。
发布于 2017-03-10 10:53:32
在webpack.common.js中,new ContextReplacementPlugin( /angular(\\|\/)core(\\|\/)@angular/, path.resolve(__dirname, '../src') )
为我的webpack工作
发布于 2017-05-12 09:27:12
在此配置下不会出现任何问题:
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('../src'),
{}
),
确保helpers.root上有两个点,而不是一个点。('../src')
https://stackoverflow.com/questions/42557614
复制相似问题