使用npm react-tools编译jsx

虽然react-tools已经被弃用,但是对于只想编译JSX的项目仍然可以使用。

首先安装好nodejs运行环境。

用如下命令安装nrm(NPM registry 管理工具):

$ npm install -g nrm
npm WARN deprecated [email protected]: 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
+ [email protected]
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 [email protected]: 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
+ [email protected]
added 31 packages in 59.379s

编译reaxt jsx模板:

$ jsx --watch src/ build/
built Module("index")
["index"]


你可能感兴趣的:(React)