CageFS make Node.js available to all users by default
On CloudLinux server, when you install alt-nodejs packages, binary files get installed at
1 |
/opt/alt/alt-nodejs16/root/bin/node |
When SSH into a user and run the command “node”, it won’t work. When deploying Node.js application with Cpanel, you will be given a command, that is used to switch to the environment with specific version of node.js the application is using.
If you want to make node.js available to all users by default, even with out a node.js application configured, you do the following
1 2 3 |
ln -s /opt/alt/alt-nodejs16/root/bin/node /usr/bin/node ln -s /opt/alt/alt-nodejs16/root/bin/npm /usr/bin/npm ln -s /opt/alt/alt-nodejs16/root/bin/npx /usr/bin/npx |
This will make “alt-nodejs16” as the default Node.js, if you need to use another version of Node.js default, change the paths as required. If you don’t have it installed, install it with
1 |
yum install -y alt-nodejs16 |
Create file
1 |
vi /etc/cagefs/conf.d/node.cfg |
Add following content
1 2 3 |
[node] comment=Node paths=/usr/bin/node, /usr/bin/npm, /usr/bin/npx |
Update CafeFS and remount all users
1 2 |
cagefsctl --force-update cagefsctl -M |
Now Node.js will be available to all users by default.
Back to CageFS