2016-12-28 76 views
1

用的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依賴關係?

回答

3

我認爲你缺少.js擴展您的resolve內的的WebPack配置也因爲它,你越來越Module not foundcore.umd.js

resolve: { 
    extensions: ['', '.js' , '.webpack.js', '.web.js', '.ts'] 
} 
+0

這就是它!謝謝你的簡潔明瞭的解釋。 – aiokos

+0

不客氣。 :) – ranakrunal9

1

您需要導入主題:

import { Subject } from 'rxjs/Subject';