title: Error messages eaten somewhere along exec-maven-plugin > Node.js > r.js
body: <p>We're using <a href="http://mojo.codehaus.org/exec-maven-plugin/" rel="noreferrer">exec-maven-plugin</a> to run RequireJS's optimizer (r.js) under Node.js (because it's a lot faster than Rhino):</p>
  
  <pre><code>&lt;plugin&gt;
      &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
      &lt;artifactId&gt;exec-maven-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.2&lt;/version&gt;
      &lt;executions&gt;
          &lt;execution&gt;
              &lt;id&gt;compile-js&lt;/id&gt;
              &lt;phase&gt;prepare-package&lt;/phase&gt;
              &lt;goals&gt;
                  &lt;goal&gt;exec&lt;/goal&gt;
              &lt;/goals&gt;
              &lt;configuration&gt;
                  &lt;executable&gt;${node.executable}&lt;/executable&gt;
                  &lt;arguments&gt;
                      &lt;argument&gt;${project.build.directory}/dependency/requirejs/r.js&lt;/argument&gt;
                      &lt;argument&gt;-o&lt;/argument&gt;
                  &lt;/arguments&gt;
              &lt;/configuration&gt;
          &lt;/execution&gt;
      &lt;/executions&gt;
  &lt;/plugin&gt;
  </code></pre>
  
  <p>The issue is, whenever there's any issue during compilation, the error messages that r.js is supposed to blurt out are not shown in Maven's console output. What I do to troubleshoot is, I rerun the Maven command with the -X flag to get debug output so that exec-maven-plugin outputs the actual command being executed. It's something like:</p>
  
  <pre>
  project-root/target/dependency/node/node \
      project-root/target/dependency/requirejs/r.js \
      -o src/main/webapp/app.build.json
  </pre>
  
  <p>When I run the command manually from the command line, I then get the actual compilation errors in the console and then proceed to fixing them.</p>
  
  <p>I've experimented with redirecting stderr to stdout with <code>2&gt;&amp;1</code> to no avail (on Windows) because I couldn't immediately find a way to make exec-maven-plugin like the redirection bit as an argument. I didn't pursue that route too far because it's just a wild guess that this is a stderr/stdout issue -- it could be, but I'm merely speculating.</p>
  
  <p>Any pointers to as to what may be happening, or any suggestions for further diagnostic steps that I can take? Please remember there are multiple moving parts in this problem: Maven, exec-maven-plugin, Node.js, r.js, and one tired head.</p>
  
  <p>P.S. I'm considering giving <a href="https://github.com/mcheely/requirejs-maven-plugin" rel="noreferrer">requirejs-maven-plugin</a> a shot as a last resort because the project timeline doesn't allow me to do a complete overhaul of the POM right now. I'm trying to see if there's anything I can do with the current setup.</p>