2
votes

I can't see the output to console.log when I build JavaScript files using a custom Node.js build system in Sublime Text (build 3083) on Linux.

When I try to build jstest.js which contains just console.log("Hello world!"); Sublime Text's console reports Running /usr/bin/node /home/sophie/scripts/jstest.js and that the build is successful, but I do not see the expected "Hello world!" output.

If I execute node jstest.js in my Linux terminal, "Hello world!" is properly output, as expected.

I have node installed at /usr/bin/node. The file jstest.js is saved to disk (apparently, Sublime Text will not build unless the file is saved). I'm using the following custom build system (and it is selected before building, of course):

{
  "cmd": ["/usr/bin/node", "$file"],
  "selector": "*.js"    
}

I've tried setting the location to just "node" and also removed the "selector" option, but neither had any effect, there's still no console.log output.

I've looked through a few similar questions and answers here (that's where I obtained the build system code), but nothing has solved the issue for me, yet. Any suggestions?

3
For me works without problems, on Mac OSX, if you run "which node" on you terminal what you get?. - Gonzalo Bahamondez
I mentioned the location of node in my question, /usr/bin/node. which node confirms that location. - Andy Forceno
Maybe try adding "path": "/usr/bin:$PATH" to your build. I'm not really sure why it isn't working if it is successfully building with Node. - Saad
That didn't seem to have any effect. Am I supposed to have some kind of pane enabled? I tried selecting Tools -> Build Results -> Show build results, but nothing happened when I clicked it. - Andy Forceno

3 Answers

2
votes

Apparently, the issue was a bug either with Sublime Text itself, or the Material Design (https://github.com/equinusocio/material-theme) theme I am using. To solve the issue, I did the following:

  1. Switch to the default Sublime Text theme
  2. Build the JS file using the custom Node.JS build system, confirm console.log output
  3. Switch back to desired theme
  4. Build the file again, console.log output should be visible

That worked for me, at least.

1
votes

Try dropping the semi-colon at the end of your line of code, which would give you the following:- console.log("Hello Javascript World!") There is no semi-colon at the end of the code line, save the file and build. Be sure Node is selected as the build system.

1
votes

An alternative would be to use: debug("output here"); This would replace console.log("output here");