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. python - 爬蟲模擬登錄后,爬取csdn后臺文章列表遇到的問題2. javascript - 求幫助 , ATOM不顯示界面!!!!3. javascript - angular使從elastichearch中取出的文本高亮顯示,如圖所示4. 視頻文件不能播放,怎么辦?5. python bottle跑起來以后,定時執行的任務為什么每次都重復(多)執行一次?6. mysql - 分庫分表、分區、讀寫分離 這些都是用在什么場景下 ,會帶來哪些效率或者其他方面的好處7. javascript - ios返回不執行js怎么解決?8. javascript - 移動端自適應9. html5 - HTML代碼中的文字亂碼是怎么回事?10. mysql 查詢身份證號字段值有效的數據
