Howto: run Node 14 on DreamHost

I was recently looking into how to run node version 14 on dreamhost
I think I’ve figured it out so I’ve put the details below
The main cause of the problem tends to be that node obsoleted the use of the “GLOBAL” alias around version 14
Fortunately swapping “GLOBAL” with “global” is an easy answer.

The below is using node v14.17.6, I put some details on installing in this other post (which is the same as the default dreamhost info)

The below is how to get node 14 running by copying / modifying / running the passenger loader script

Copy Passenger node loader script

First lets copy the loader script across to a local directory so we can modify it

cd ~
mkdir nodejs-wrapper
cd nodejs-wrapper
cp /usr/share/passenger/helper-scripts/node-loader.js node-loader.js

Modify the loader script

Next inside this script we need to make one simple change, to change “GLOBAL” to “global”
The below command should modify the script we copied

sed -i 's/GLOBAL/global/g' node-loader.js

Setup a Wrapper Script

Finally we need a wrapper script to call our node-loader.js file instead of the default one
Remember to replace username with your username


/home/username/.nvm/versions/node/v14.17.6/bin/node /home/username/nodejs-wrapper/node-loader.js

Normally passenger passes in the path to the node-loader script as a single argument, we’re ignoring this here and instead calling node with a path to our copy of the loader script instead.

Lets make the script executable

chmod +x nodejs-wrapper-script

Setup Passenger NodeJs

The next step is to edit the .htaccess

cd ~/
vi .htaccess

Then add / change the following line

PassengerNodejs /home/username/nodejs-wrapper/nodejs-wrapper-script

Restart Passenger

As a last step restart Passenger, run this from within the same site directory

mkdir -p tmp && touch tmp/restart.txt


If you’ve used the default hello world js script as a test then you should see something like this when visiting the site

Hello World. This page is running Node.js version: v14.17.6
1 Like

Just tried this with v16.10.0 and that seems to work as well

One thing to watch our for if DreamHost ever migrate from passenger 5.0 to 5.1 at some point then this might stop the site from working since the node-loader.js may change in terms of the passenger api that’s used.
But if that does happen then in theory this workaround shouldn’t be needed anymore anyways based on what I’ve seen of the passenger sources.

1 Like