8

I'm getting the following error when trying to use ExecJS:

execjs.RuntimeUnavailable: Node.js (V8) runtime is not available on this system

I have node.js installed on my machine (Ubuntu 14.04). Which Node outputs /usr/bin/node

Any ideas?

Ricky Barnett
  • 1,130
  • 3
  • 15
  • 32
  • How did you install node.js, via the default repos, added a repo, nvm? – tsturzl Aug 20 '15 at 19:04
  • Digital Ocean - NodeJS package – Ricky Barnett Aug 20 '15 at 19:12
  • Can you output `execjs.get().name`? Have you tried setting a `EXECJS_RUNTIME` environment variable to `"Node"` explicitly? – tsturzl Aug 20 '15 at 22:45
  • @tsturzl `_auto_detect raise RuntimeUnavailable("Could not find a JavaScript runtime.") execjs.RuntimeUnavailable: Could not find a JavaScript runtime.` – Ricky Barnett Aug 21 '15 at 09:44
  • Have you tried setting the environment variable posted above? – tsturzl Aug 21 '15 at 20:44
  • Try `ln -s /usr/bin/node /usr/bin/nodejs` Looking at the source it basically just tries both of these commands. Perhaps there is a bug that fails to find the node.js runtime unless its added to your environment as `nodejs`. Ubuntu usually installs node.js executable to the path `/usr/bin/nodejs` rather than just `/usr/bin/node`. So perhaps there is a bug that slipped through the cracks because the may be using a ubuntu box for testing. I'm not certain, but its worth a shot. – tsturzl Aug 21 '15 at 20:51
  • Either way I would classify this as a bug. I'd recommend creating a ticket at [the PyExecJs github](https://github.com/doloopwhile/PyExecJS/issues). The code isn't that complicated otherwise, its just looking to see what runtimes exist then passing the JS as an argument to one of the available runtimes. I'd imagine you can just adjust the library to find your runtime and send a PR to the maintainer. – tsturzl Aug 21 '15 at 20:55
  • Alternatively you can still use V8 via the `PyV8` dependency, however this doesn't include commonjs or core modules from node.js and will likely be a different version of V8. I'm not sure if you need/want these things or not, but it may be a quick and easy fix. – tsturzl Aug 21 '15 at 21:09
  • What is the output of `echo $PATH`? Perhaps your environment is jacked up. – tsturzl Aug 21 '15 at 21:19
  • http://stackoverflow.com/questions/18130164/nodejs-vs-node-on-ubuntu-12-04 – dsgdfg Aug 25 '15 at 17:02

5 Answers5

2

Have you seen this similar issue

They resolve the problem by linking node under /usr/local/bin/node

ln -s /usr/local/bin/node /usr/bin/node
Community
  • 1
  • 1
kmandov
  • 3,130
  • 16
  • 15
  • I don't think this is what I'm looking for as my `Which Node` already outputs `/usr/bin/node` so creating a link from local wouldn't do anything – Ricky Barnett Aug 13 '15 at 14:45
  • This worked for me in getting Intellij Idea to recognize node installed via NVM – Rombus Apr 29 '19 at 21:22
2

Hello I've had the same issue before and this solved it:

Node.js not found by Rails / execjs

0

When you are trying to use ExecJS, what user are you trying to run as? the ENV path for node may be not be available to the account which is trying to execute the ExecJS. May be this could be a dumb idea but have you tried re-installing nodejs?

sudo apt-get install nodejs

nixdaemon
  • 121
  • 6
0

To get some insight what's happening, you might want to try "strace yourapp" (system call tracer), or strace -p $PID , (-f helps following forks) then grep the output for node. You will see what it was trying to open/start before throwing the error.

That way you will have something to look for in configuration or environment, that must be changed to the path your node could really be found.

PetrosHu
  • 303
  • 2
  • 9
0

Make sure you really have file /usr/bin/node. If it is a symlink, make sure the target is exists and valid.

I know that which node gave you the result but just make sure it's same in the python's environtment.

print os.environ.get('PATH', '')

And make sure your /usr/bin/node is executable by current user.

$ node --version
Hereblur
  • 2,084
  • 1
  • 19
  • 22