title: Run JavaScript in Sublime Text
body: <p>I have searched and found a way to make JavaScript works on SublimeText. The way is like that in steps:</p>
  
  <ul>
  <li>Sublime Text > File > New File > Type:
  console.log("Hello World");</li>
  <li>Press Ctrl + S (Save) > script.js</li>
  <li><p>Install Node.js</p></li>
  <li><p>Sublime Text > Tools > Build System > New Build System > Type:</p></li>
  </ul>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    {
       "cmd": ["node", "$file"],
       "selector": "source.js"
      }</code></pre>
  </div>
  </div>
  </p>
  
  <ul>
  <li>Save As Node.sublime-build</li>
  <li>Sublime Text > Tools > Build System > Node</li>
  </ul>
  
  <p>That worked well and I can get the console results well
  Now how can I use or refer to the index.html file?
  To be more specific I have two files: index.html and script.js and I need to run the JS on sublime text but I got
  <code>ReferenceError: document is not defined</code> on such a line</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var output = document.getElementById('output');</code></pre>
  </div>
  </div>
  </p>