Question

I'm trying to set up a CoffeeScript build system in Sublime Text 3, but I keep getting the following error:

env: node: No such file or directory
[Finished in 0.0s with exit code 127]
[cmd: ['coffee', '-o','/Users/jcourtdemone/Sites/autotempest.com/new_design_sandbox/static/script', '-cw', '/Users/jcourtdemone/Sites/autotempest.com/new_design_sandbox/static/coffee']]
[dir: /Users/jcourtdemone/Sites/autotempest.com/new_design_sandbox/static/coffee]
[path: /usr/bin:/bin:/usr/sbin:/sbin]

My build system looks like this:

{
    "name": "Coffee - AT",
    "cmd": ["coffee","-o","${project_path:${folder}}/static/script","-cw","${project_path:${folder}}/static/coffee"],
    "selector": "source.coffee",
    "path":"/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/lib/node_modules/coffee-script/bin"
}

Two things strange about this.

1) It says it's looking in /usr/bin where a symlink to coffee exists.

2) Because of (1), I overrode $PATH to include the actual location of coffee which is /usr/local/lib/node_modules/coffee-script/bin, but for some reason, $PATH isn't being overridden properly, it's sticking with the default $PATH.

Things to note:

i) I've verified that all paths are correct and pass normally through a regular terminal command.

ii) Tried with a "shell": true variable in the build system.

iii) I have another build system for Compass like this that works fine.

Anyone run into similar problems or issues? Any ideas?

Was it helpful?

Solution

In Terminal, type which node, then create a symlink to that location in /usr/bin. For example, if node lives in /usr/local/bin, create the symlink like so:

sudo ln -s /usr/local/bin/node /usr/bin/node

If you look at the source of your coffee script, you'll probably find that the first line is something along the lines of:

#!/usr/bin/env node

Exit code 127 in Sublime means that an env command has failed - so in your case, the build system is finding coffee, but it can't execute it because the node binary isn't in Sublime's default search path.

There are two ways to redefine the default search path for Sublime. The first (and easiest) is to always open it from the command line using the built-in subl command. If you're an OS X power user and don't mind messing with important system settings, check out my post on unix.SE on how to alter the default /usr/bin:/bin:/usr/sbin:/sbin path that you're seeing. Be forewarned that if you don't do things correctly, you may break your system. However, if you're running Mountain Lion (10.8.X) and you follow the instructions exactly, everything should be fine. (I haven't upgraded to Mavericks, so no guarantees on whether it'll work with that version.)

OTHER TIPS

How to solve the problem under an Ubuntu System

The fact is "coffee" command will call /usr/bin/node to continue its work, however, the original "node" command for the node application on an Ubuntu system is changed from "node" to "nodejs" to avoid name conflicting. That is the reason, the shell will compliant you "/usr/bin/env: node: No such file or directory". whenever you type

$ coffee

To solve the bug, just let the shell find something named "node" in its default searching path, and this so-called "node" will promote nodejs. The command "nodejs" lies under path of /usr/bin/nodejs.

We will use symbol link to link "node" with nodejs, and place the link "node" within the default searching path, so that the shell will find it.

sudo ln -s /usr/bin/nodejs /usr/bin/node 

But beware, make sure that you do NOT have another "node" command under /usr/bin/, you can check it by try to run

$ which node

I do NOT know what to do if you have installed another "node" application.

In Ubuntu you can install the package nodejs-legacy

sudo apt-get install nodejs-legacy

this package just create a symbolic link to binary nodejs

You should be able to fix this all in your build system without needing to add a symlink on your machine.

For example if node lives in /usr/local/bin/node all you have to do is change the path in your build_system to be:

"path": "/usr/local/bin:$PATH"

I had the same problem with Sublime Text 2. Creating this sublime build worked for me:

{
"cmd": ["coffee", "-c", "$file"],
"selector" : "source.coffee",
"path" : "/usr/local/lib/node_modules/coffee-script/bin/:/usr/local/bin:$PATH"  
}

The following code worked for me in Ubuntu 14.04:

**$ sudo apt-get install NodeJS-legacy** 

The other problem was the version checking frameworks such as for e.g: gulp -v the same code also solved this problem.

Type the next in the console:

sudo ln -s /usr/bin/nodejs /usr/bin/node
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top