在 Windows 中反应 JSX 转换器 [英] React JSX transformer in Windows

查看:29
本文介绍了在 Windows 中反应 JSX 转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好像什么都没做?根据此提交,JSX 转换器现在应该可以工作了.

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.

当我运行这个命令时,它没有错误返回并且似乎运行良好.然而,绝对没有任何事情发生.我在 C:\dev\_res\jsx\test.js 中有一些测试 JSX 代码,应该在进行更改后进行转换.

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:

  • 尝试转换直接文件,可执行文件吐出正确的用法文档
  • 使用选项 -x js 没有效果
  • --harmony 没有效果
  • 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

推荐答案

问题在于 JSX Transformer 如何处理 Windows 驱动器.如果输入/输出目录包含 :,则不会引发错误,并且它仅返回退出代码 0.

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.

如果您对 Node 可执行文件和 node_modules 目录所在的代码使用不同的驱动器,则需要将辅助驱动器安装到一个文件夹 (关于如何执行此操作的好教程)并改用文件夹.

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/

到:

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

... 如果您将 S: 驱动器安装到 C: 驱动器根目录中名为 S 的文件夹.然后 JSX Transformer 将继续处理所有文件并按预期继续观察目录.

... 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.

这篇关于在 Windows 中反应 JSX 转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆