RxJS解决错误当角2的WebPack
问题描述:
用的WebPack建设时,我的角2的应用程序,我收到以下错误大厦:RxJS解决错误当角2的WebPack
ERROR在
./~/@angular/core/bundles/core.umd.js
模块未发现:错误无法解析模块“rxjs /主题”在
C:\...\node_modules\@angular\core\bundles
@
./~/@angular/core/bundles/core.umd.js
7:84-107
这里是我的package.json:
...
"devDependencies": {
"ts-loader": "^1.3.3",
"typescript": "~2.0.10",
"webpack": "^1.14.0"
},
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.9",
"rxjs": "^5.0.1",
"zone.js": "^0.7.4"
}
}
而且我webpack.config.js
:
module.exports = {
entry: './src/modules/app/main.ts',
output: {
path: './src/dist/',
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.ts']
},
module: {
loaders: [
{
exclude: /node_modules/,
test: /\.ts?$/,
loader: 'ts-loader'
}
]
}
}
请注意,我的角2个的应用程序生命的文件夹/src/modules/app/main.ts
英寸
为什么Webpack无法解决RxJS
依赖关系?
答
我认为你缺少.js
扩展您的resolve
内的的WebPack配置也因为它,你越来越Module not found
为core.umd.js
:
resolve: {
extensions: ['', '.js' , '.webpack.js', '.web.js', '.ts']
}
答
您需要导入主题:
import { Subject } from 'rxjs/Subject';
这就是它!谢谢你的简洁明了的解释。 – aiokos
不客气。 :) – ranakrunal9