0

I have read this post on an error with node in Sublime Text 2, this post on finding where node was installed, and this post on what seems to be the same issue, but none of them have helped so far. I would also prefer to use node.js. Please bear in mind, I am a programming newbie, so descriptions of locations of directories will have be absolute path names in order for me to understand.

I followed the instructions here, and my Node.sublime-build file looks like this:

{ "cmd": ["node", "$file", "$file_base_name"], "working_dir": "${project_path:${folder}}", "selector": "*.js" } 

I restarted Sublime Text 2, but it didn't work. I restarted my computer, but to no avail. Currently, /usr/local/bin is where node is stored, and my $PATH contains that directory. At least, I think. My $PATH (I am in a bash_profile) looks like this:

-bash: /Users/David/.rvm/gems/ruby-2.0.0-p353/bin:/Users/David/.rvm/gems/ruby-2.0.0-p353@global/bin:/Users/David/.rvm/rubies/ruby-2.0.0-p353/bin:/Users/David/.rvm/bin:/usr/local/heroku/bin:/Users/David/.rbenv/shims:/Users/David/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin: No such file or directory 

I think the solution may be found in the line in the Sublime Text 2 console error messages that reads,

[path: /usr/bin:/bin:/usr/sbin:/sbin] 

Do I need to insert /usr/local/bin: into it? If so, how? I am running Mac OS X 10.7.5. Even if there's another thread that I haven't found, I'd gladly forgo reputation points in order to get the solution to my problem.

Cheers!

2
  • I apologize. I forgot to post the error! The file I'm running is called fizzbuzz.js. [Errno 2] No such file or directory [cmd: [u'nodejs', u'/Users/David/dev/HTML/lab/12-20-13/fizzbuzz.js']] [dir: /Users/David/dev/HTML/lab/12-20-13] [path: /usr/bin:/bin:/usr/sbin:/sbin] [Finished] Commented Dec 21, 2013 at 15:03
  • You might want to go through this and this Commented Dec 21, 2013 at 15:08

1 Answer 1

0

There are three options for getting your build systems to work.

First, you can edit your Node.sublime-build file to look like this:

{ "cmd": ["/usr/local/bin/node", "$file", "$file_base_name"], "working_dir": "${project_path:${folder}}", "selector": "*.js" } 

by adding /usr/local/bin/ to the beginning of the node command to give its fully qualified path.


Alternatively, since you're on Lion (this doesn't work on Mt Lion), you can alter the path for Dock-launched programs (by default it's /usr/bin:/bin:/usr/sbin:/sbin, as you've seen). From Terminal, run the following:

launchctl setenv PATH $PATH 

(you may have to prefix it with sudo, I'm not sure). The, run:

osascript -e 'tell app "Dock" to quit' 

and restart Sublime. This has the advantage of allowing other build systems (I'm especially thinking of Ruby, since you're using RVM) to work out of the box, without messing around with their .sublime-build files as well. For this and the next option, you'll need to remember to update the path when you update Ruby.


The third option, which is necessary on Mountain Lion (not sure about Mavericks) is outlined in my answer here. Basically, you need to edit /etc/launchd.conf (or create it if it doesn't exist) to define PATH, then save and reboot. This is necessary because the launchctl command on 10.8 doesn't do what we want it to do. This option may also work on Lion, but I haven't tested it, since I had already upgraded to Mt Lion before I developed it.

I hope this all helps. Good luck!

Sign up to request clarification or add additional context in comments.

6 Comments

Matt, I followed the instructions at stackexchange, but the only thing that changed was my error message when I build using node: ('[path: /usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/Users/David/bin:/path/to/gems/bin]').
@David - what happens if you change the .sublime-build file like in option 1? Also, what is the output when you run which node at the command line?
@David - wait a sec, I just reread your error message. It says it's looking for nodejs, while your build file says node. Are you sure you're building with the correct file?
I apologize. I hastily replied before I changed the Node.sublime-build file again. Everything is working just fine. As far as updating the path when I update Ruby, will RVM take care of that or I'll just figure out how to cross that bridge when I get to it?
@David - you'll have to update it yourself, since RVM doesn't know to look there.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.