Node.js support past version 6


#1

Is Node v6 the only version available or can we upgrade it, and how? We have apps that use features that Node v6 doesn’t support.


#2

You can configure on a per-app basis to use a different Node version (or Python or Ruby version for that matter).

Do an scl install of the later version that you want (looks like 8 and 10 are available https://www.softwarecollections.org/en/scls/?search=node) but make sure you keep Node.js 6 SCL for the default.

Then in each app you can drop in a bin/node script that will load the different SCL prior to starting the app. I’ll share an example in a moment.


#3

I think this will work though I haven’t tested it yet. Make the script executable via chmod 755 and have this be the contents:

#!/bin/bash

source scl_source enable rh-nodejs10
exec /bin/env node "$@"

We have configured the PUN to look here first, and if this file exists Passenger will execute it instead of the default:


#4

To clarify, the script you will add will go under the root of your app. So if your app is /var/www/ood/apps/sys/my_custom_node10_app you would add the script /var/www/ood/apps/sys/my_custom_node10_app/bin/node.


#5

You can also change the node version used across all the apps and optionally use the trick above just with the core apps that have been tested with Node.js 6. Or you can risk rebuilding the core apps with a later Node.js.

Let me know if you want to see this solution.


#6

I think for the second solution, changing the node.js to a different version across the board, you would add an /etc/ood/profile file with this content:

source /opt/ood/nginx_stage/etc/profile
source scl_source enable rh-nodejs10

#7

Note /etc/ood/profile is source by root in the /opt/ood/nginx_stage/sbin/nginx_stage script during the privilege escalation when starting the user’s PUN, so be careful what you put here.


#9

This method worked for us.

We added the script and named it “node” within the file structure discussed below. Changed mode to executable and we were able to get this working.

However as @efranz mentioned there was blow back from setting the node version globally.


#10

Great I’m glad it worked!