Reputation: 1265
I am getting the following error when building my Angular 2 application with Webpack:
ERROR in
./~/@angular/core/bundles/core.umd.js
Module not found: ErrorCannot resolve module 'rxjs/Subject' in
C:\...\node_modules\@angular\core\bundles
@
./~/@angular/core/bundles/core.umd.js
7:84-107
Here is my 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"
}
}
And my 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'
}
]
}
}
Note that my Angular 2 application lives in the folder /src/modules/app/main.ts
.
Why is Webpack having trouble resolving the RxJS
dependencies?
Upvotes: 1
Views: 614
Reputation: 13558
I think you are missing .js
extension inside your resolve
for webpack config and because of it you are getting Module not found
for core.umd.js
:
resolve: {
extensions: ['', '.js' , '.webpack.js', '.web.js', '.ts']
}
Upvotes: 3
Reputation: 16441
You need to import Subject:
import { Subject } from 'rxjs/Subject';
Upvotes: 1