React JSX transformer in Windows

霸气de小男生 提交于 2019-12-11 20:13:10

问题


It seems to do nothing? According to this commit, the JSX transformer should work now.

The command I'm attempting to use at the moment:

C:\Node> node node_modules/react-tools/bin/jsx --watch S:/dev/_res/jsx/ S:/dev/_res/js/

Changing the / to \ has no effect. Neither does double-quoting the paths.

When I run this command it returns with no errors and seems to have run fine. However absolutely nothing happens. I have some test JSX code in C:\dev\_res\jsx\test.js which should transpile after making a change.

Few extras tried now:

  • Trying to convert a direct file, the executable spits out the proper usage doc
  • Using option -x js has no effect
  • --harmony has no effect

回答1:


The problem lies within how the JSX Tranformer deals with Windows drives. No error is thrown if the input/output directory contains a : and it simply returns with an exit code of 0.

If you're using a different drive for code from where the Node executable and node_modules directory lies, you need to mount the secondary drive to a folder (good tutorial on how to do this) and use the folder instead.

So in the path example above, it would go from:

C:\Node>node node_modules/react-tools/bin/jsx --watch S:/dev/_res/jsx/ S:/dev/_res/js/

to:

C:\Node>node node_modules/react-tools/bin/jsx --watch ../S/dev/_res/jsx/ ../S/dev/_res/js/

... if you mount the S: drive to a folder called S in your C: drive's root. The JSX Transformer will then proceed to process all files and continue to watch the directory as expected.



来源:https://stackoverflow.com/questions/27191585/react-jsx-transformer-in-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!