nodejs ≠ node

Josua Schmid
1 min readSep 22, 2020

In a bit older project we use theautoprefixer-rails gem (and not webpacker yet). After the version 10 update I saw following errors appear on the CI:

ActionView::Template::Error:
Autoprefixer doesn’t support Node v8.10.0. Update it.

I didn’t understand how this could happen. We use NVM to automatically install and configure node versions. So I expected it to be 10.22.1 instead of 8.10.0 .

I found out thatExecJS auto-detects the node version on the system. You can run ExecJS::Runtimes.autodetect in your Rails console to see what it chose. Interestingly this returned a hint on what was going wrong:

irb(main):007:0> ExecJS::Runtimes.autodetect
=> #<ExecJS::ExternalRuntime:0x00000000037449d0 @name="Node.js (V8)", @command=["nodejs", "node"], @runner_path="/home/semaphore/[redacted]/vendor/bundle/ruby/2.7.0/gems/execjs-2.7.0/lib/execjs/support/node_runner.js", @encoding="UTF-8", @deprecated=false, @binary="nodejs", @popen_options={:external_encoding=>"UTF-8", :internal_encoding=>#<Encoding:UTF-8>}>

The command order was wrong for me (@command=["nodejs", "node"]):

semaphore@semaphore-vm:~/[redacted]$ nodejs -v
v8.10.0
semaphore@semaphore-vm:~/[redacted]$ node -v
v10.22.1

Switching to the master branch of ExecJS fixed the problem as the order was switched here: https://github.com/rails/execjs/commit/f6dc08c58ab4e1a467f64d471ee6e0127c2f14de

Actually I made a fork https://github.com/renuo/execjs/tree/v2.7.0-renuo which should work for NVM (but not default linux installations).

--

--