ioquatix / script-runner

This package will run various script files inside of Atom. It currently supports JavaScript, CoffeeScript, Ruby, and Python. You can add more.
http://atom.io/packages/script-runner
Other
62 stars 23 forks source link

No such file or directory while trying to execute node #46

Closed abcdedf closed 8 years ago

abcdedf commented 8 years ago

I just installed script runner and wrote a simple Hello World js testing it out. When I run it, I get the above error. What could be wrong in my set up? Node installed and working.

ioquatix commented 8 years ago

What does the script look like?

erelsgl commented 8 years ago

Same error here. The contents of the file are irrelevant. The issue is probably that on Ubuntu, the program is called "nodejs" rather than "node". In atom-runner, the solution was to put the following into config.cson:

  runner:
    extensions:
      ...
    scopes:
      ...
      js: "nodejs"
      ...

This tells atom-runner to run js files using "nodejs".

But, this does not work with script-runner.

huba commented 8 years ago

Use a shebang line at the start of your script. script-runner is made to obey shebang lines.

#!/usr/bin/env node is what you want to put at the start of the file.

Also I think this post from StackOverflow is relevant. It explains how the node executable is named differently on Ubuntu and what can and should be done to mitigate the issue. Essentially you should set up a symlink at /usr/bin/node to the nodejs executable. This will make your scripts cross platform.

Alternatively you can always use the shebang line:

#!/usr/bin/env nodejs