最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React - jsx --watch does nothing after first conversion - Stack Overflow

programmeradmin4浏览0评论

I can't use in browser JSXTransformer.js even for development, because i am using require.js for loading modules. When i run jsx --watch src/ build/, actually just one jsx->js conversion is performed against files in src directory, but subsequently, if i change any file in src directory, nothing happened, no translation jsx->js (like if jsx --watch didn't noticed any changes).

I can't use in browser JSXTransformer.js even for development, because i am using require.js for loading modules. When i run jsx --watch src/ build/, actually just one jsx->js conversion is performed against files in src directory, but subsequently, if i change any file in src directory, nothing happened, no translation jsx->js (like if jsx --watch didn't noticed any changes).

Share Improve this question edited Aug 6, 2015 at 18:55 Bergi 665k160 gold badges1k silver badges1.5k bronze badges asked Mar 30, 2014 at 2:46 KrabKrab 6,7566 gold badges44 silver badges82 bronze badges 2
  • Same thing is happening to me. This worked once and only once: jsx --watch ../src/jsx ../src/js – pcorcoran Commented Mar 31, 2014 at 17:13
  • Are you running the r.js optimizer or any other JS-related build tools in addition to JSX compilation? – cantera Commented Apr 1, 2014 at 16:42
Add a comment  | 

6 Answers 6

Reset to default 20

Same happened to me.

Try this command line:

jsx --watch -x jsx src/ build/

I had the same problem, but this helped:

jsx --watch ./scr ./build

Actually it happens when you are trying to start the command from wrong folder or set the wrong path to folder from which you want to build (e.g. "src/"). Write path depends on you directory's structure. Best way to find out write path is to print the command "jsx --watch " and then use Tab to get path to directory you need or just make sure the current folder in terminal contains build/ and src/ folders.

I'm having the same issue, and maybe it's because I don't really understand how "--watch" is supposed to work. What I initial did was this: open terminal, punch in "watch" command (e.g. "jsx --watch /src /build). As soon as I did that, the terminal spit back something like "helloworld.js was built". All good.

Then I closed the terminal window and nothing worked after that.

Then I re-opened the terminal, re-typed the command, and the watch command worked.

Then I closed the terminal, and it stopped working.

I'm sensing a pattern here. Is the JSX watch command only active while the containing terminal window is open? I assumed "watch" was a "set it once and forget it" command, but it sounds like it's more ephemeral than that?

You have this issue probably bacause of the suffix of the files is jsx and not js the jsx command not recognize .jsx files.

You can do as user2038099 said: jsx --watch -x jsx src/ build/

-x, --extension File extension to assume when resolving module identifiers

or you can change the suffix of the files in the src folder to .js.

https://github.com/facebook/react/issues/4269

I had this problem running Ubuntu 14.04. The jsx command would not give any feedback regardless what arguments I passed it. I eventually ended up uninstalling node entirely and installed using the instructions for Ubuntu at https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

I was previously on nodejs v0.10.28, but now that I'm on nodejs v0.12.7 everything is working fine.

发布评论

评论列表(0)

  1. 暂无评论