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. angular.js - 请教angularjs里html和js通信的问题2. node.js - 怎么在初始化的时候使得一个子组件不加载?3. android自带时钟应用的这个效果是怎么做的4. 代码如下,java用BigDecimal四舍五入怎么还有问题呀?哪种方式是完全没有问题的?5. javascript - 关于向java后台上传base64位字符串的图片数据,求助6. 求解决方法:Parse error: syntax error, unexpected7. 新人做网站求帮助8. 老师所用的IDE开发环境是什么?9. 请问“由于 Cookie “PHPSESSID”的“SameSite”属性设置为“None”,但缺少“Secure”属性,此 Cookie 未来将被拒绝。”请问出现这个问题怎么办?10. Help!求帮助