Node.js application runtime version not set correctly by admin, how to work around it?

Pacific6110

Member
Sep 18, 2022
5
1
3
Pacific
cPanel Access Level
Website Owner
I set up a node.js application and chose node version 16. Then I also created an application with Application manager.

Then I went to the url mentioned in the app.

At that point, the default app.js file served the page and said "It works!" but it gave node version 10.

My server admin gave me the same issue in Python. I had to write a version switcher just to overcome that.

I am trying that same approach with nodejs but it's not working. I am trying to set my startup file to be startup.js, then in there, use exec to run my app.js with the correct version of node, but it's not working for some reason.

Is there an easiest way to get my app to run with node 16 besides asking the administrator to fix it? He won't. Where can I tell passenger to "use node 16"?
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
13,259
2,086
363
cPanel Access Level
Root Administrator
Hey there! On a cPanel server, unless there have been manual workarounds performed, you can only have one version of the NodeJS software in place at a time. Here is the output from a test server showing what happens when you try to instlal the nodejs16 package on a server where nodejs10 is already installed:

Code:
# yum install ea-nodejs16
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
 * EA4: 184.94.196.92
 * cpanel-addons-production-feed: 184.94.196.92
 * cpanel-plugins: 184.94.196.92
 * epel: mirror.dal.nexril.net
Resolving Dependencies
--> Running transaction check
---> Package ea-nodejs16.x86_64 0:16.18.0-1.1.1.cpanel will be installed
--> Processing Conflict: ea-nodejs10-10.24.1-2.2.1.cpanel.x86_64 conflicts ea4-nodejs
--> Processing Conflict: ea-nodejs16-16.18.0-1.1.1.cpanel.x86_64 conflicts ea4-nodejs
--> Processing Conflict: ea-nodejs16-16.18.0-1.1.1.cpanel.x86_64 conflicts ea-nodejs10
--> Finished Dependency Resolution
Error: ea-nodejs16 conflicts with ea-nodejs10-10.24.1-2.2.1.cpanel.x86_64
Error: ea-nodejs10 conflicts with ea-nodejs16-16.18.0-1.1.1.cpanel.x86_64
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
This EasyApache 4 interface in WHM would also give a similar error.

Do you know if version 16 is installed on the server at all? When you say you "chose" version 16, can you provide me with more details on that portion of your work?
 

Pacific6110

Member
Sep 18, 2022
5
1
3
Pacific
cPanel Access Level
Website Owner
Hey there! On a cPanel server, unless there have been manual workarounds performed, you can only have one version of the NodeJS software in place at a time. Here is the output from a test server showing what happens when you try to instlal the nodejs16 package on a server where nodejs10 is already installed:

Code:
# yum install ea-nodejs16
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 184.94.196.92
* cpanel-addons-production-feed: 184.94.196.92
* cpanel-plugins: 184.94.196.92
* epel: mirror.dal.nexril.net
Resolving Dependencies
--> Running transaction check
---> Package ea-nodejs16.x86_64 0:16.18.0-1.1.1.cpanel will be installed
--> Processing Conflict: ea-nodejs10-10.24.1-2.2.1.cpanel.x86_64 conflicts ea4-nodejs
--> Processing Conflict: ea-nodejs16-16.18.0-1.1.1.cpanel.x86_64 conflicts ea4-nodejs
--> Processing Conflict: ea-nodejs16-16.18.0-1.1.1.cpanel.x86_64 conflicts ea-nodejs10
--> Finished Dependency Resolution
Error: ea-nodejs16 conflicts with ea-nodejs10-10.24.1-2.2.1.cpanel.x86_64
Error: ea-nodejs10 conflicts with ea-nodejs16-16.18.0-1.1.1.cpanel.x86_64
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
This EasyApache 4 interface in WHM would also give a similar error.

Do you know if version 16 is installed on the server at all? When you say you "chose" version 16, can you provide me with more details on that portion of your work?
Yes, version 16 is on the server. I'll attach two screen shots to show that. First, the node.js application tool shows node 16 as a choice that apparently "works" in the sense it says it's running on it.

Secondly, the ssh client will allow me to run my app with node 16. See screen shots. Thank you so much for helping me.

1667237152686.png1667237152686.png

and
1667237229719.png1667237152686.png1667237229719.png

Thanks again!
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
13,259
2,086
363
cPanel Access Level
Root Administrator
Thanks for the additional details. Under step 5 here:


it mentions setting the path to specifically call the nodejs16 version. Did you also adjust the PATH on the machine?
 

Pacific6110

Member
Sep 18, 2022
5
1
3
Pacific
cPanel Access Level
Website Owner
You said step 5, but do you actually mean step 2 under "Test the Application"?

That step says to invoke node 16 from the command line when testing the application (from the command line). Like this,

<code>
/opt/cpanel/ea-nodejs16/bin/node app.js
</code>

It also mentions you can add node 16 to your PATH variable and then put that EXPORT PATH command in your `.bashrc` file.

<code>
export PATH=/opt/cpanel/ea-nodejs16/bin/:$PATH
</code>

On my server, the correct path to node 16 is actually `/opt/alt/alt-nodejs16/root/usr/bin/node`, but same difference.

<code>
export PATH=/opt/alt/alt-nodejs16/root/usr/bin/node:$PATH
</code>

All that effects the bash terminal sessions. So now, when I go into ssh terminal and check `node--version`, it says node 16.

However, the application still shows node 10 at runtime. The bash settings do not affect the version of node that passenger chooses when it launches a node application.
Passenger does not look at .bashrc or .bashprofile when executing the command line for a node application.

I also tried adding that path to "ENVIRONMENT VARIABLES" on the application setup page in cpanel Application Manager and also the Node.js tool page for the application, with no success.

What file(s) does passenger look at when launching a node application? Where does passenger get the version of node, or the PATH variable that it uses?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
13,259
2,086
363
cPanel Access Level
Root Administrator
No, I meant the blue note under step 5 under "Testing" about the bashrc, but you've already done that.

It's possible there is a server version that is different than the installed EasyApache version, but without root access to the machine we'd really just be guessing.
 

Pacific6110

Member
Sep 18, 2022
5
1
3
Pacific
cPanel Access Level
Website Owner
Situation Update:

The administrators have now deleted ea-nodejs10 folder, which broke passenger for every single nodejs app, since it's still looking for that specific node bin path

Even tho node10 no longer exists on the server, passenger is still specifically looking for that binary. Where is "ea-nodejs10" referenced in the passenger system?

It kinda appears like I have read access to the entire server. How can I search all files that contain the string "ea-nodejs10" so I can help point the administrators to actually fix the configuration instead of just patching it with a symbolic link?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
13,259
2,086
363
cPanel Access Level
Root Administrator
What you seeing can't normally happen on a standard cPanel server. It would be best to have your provider submit a ticket to our team, as having both versions of NodeJS installed without using the CloudLinux Selector tool shouldn't be an option, and likely caused issued with the system.