虽然react-tools已经被弃用,但是对于只想编译JSX的项目仍然可以使用。
首先安装好nodejs运行环境。
用如下命令安装nrm(NPM registry 管理工具):
$ npm install -g nrm
npm WARN deprecated coffee-script@1.7.1: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
C:\Users\******\AppData\Roaming\npm\nrm -> C:\Users\******\AppData\Roaming\npm\node_modules\nrm\cli.js
+ nrm@1.0.2
added 328 packages in 124.447s
$ nrm ls
npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
* taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
$ nrm use cnpm
Registry has been set to: http://r.cnpmjs.org/
安装react-tools:
$ npm install -g react-tools
npm WARN deprecated react-tools@0.13.3: react-tools is deprecated. For more information, visit https://fb.me/react-tools-deprecated
C:\Users\******\AppData\Roaming\npm\jsx -> C:\Users\******\AppData\Roaming\npm\node_modules\react-tools\bin\jsx
+ react-tools@0.13.3
added 31 packages in 59.379s
编译reaxt jsx模板:
$ jsx --watch src/ build/
built Module("index")
["index"]