angular.js - angular2+webpack編譯錯誤
問題描述
請大家幫忙看看,憋了一上午了,在線等,先謝謝了!錯誤信息:
ERROR in /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/@angular/core/src/facade/async.d.ts(8,28): error TS2307: Cannot find module ’rxjs/Observable’.ERROR in /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/@angular/core/src/facade/async.d.ts(9,25): error TS2307: Cannot find module ’rxjs/Subject’.ERROR in /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/@angular/core/src/facade/async.d.ts(10,28): error TS2307: Cannot find module ’rxjs/Observable’.ERROR in /Users/honpery/personal_project/honpery_com/admin_rewrite/node_modules/@angular/core/src/facade/async.d.ts(11,25): error TS2307: Cannot find module ’rxjs/Subject’.
tsconfig.json
{ 'compilerOptions': {'target': 'es5','module': 'commonjs','moduleResolution': 'node','sourceMap': true,'experimentalDecorators': true }, 'buildOnSave': false, 'compileOnSave': false, 'exclude': ['node_modules' ]}
index.ts
import 'es6-shim';import 'rx';import {Component} from ’@angular/core’;
問題解答
回答1:已經找到答案,庫用錯了,應該是rxjs而不是rx。
回答2:說是rxjs/Observable沒找到,你裝了rx了么?npm install --save rxjs@5.0.0-beta.6
還有,再去掉import 'rx';試試。
最后,對照webpack+angular2搭環境看看還有哪里有區別
相關文章:
1. index.php錯誤,求指點2. html5 - 設置判斷條件,設置ng-click無法跳轉3. java - spring boot 啟動時報SunCertPathBuilderException4. macos - mac下docker如何設置代理5. 微信開放平臺 - android 微信支付后點完成按鈕,后回調打開第三方頁面,屏幕閃動,求解決方法6. 微信公眾號在線生成二維碼帶參數怎么搞?7. PHP單例模式8. javascript - 微信報redirect_uri參數錯誤9. html5 - h5寫的app用的webview,用手機瀏覽器打開不顯示?10. html - 如何用css令背景圖能夠撐滿本身會滾動的頁面?
