Skip to content

Instantly share code, notes, and snippets.

@mcnamee
Last active October 16, 2023 00:40
Show Gist options
  • Save mcnamee/3fc5b348b37e6657dbc2b99ed7bdb9e0 to your computer and use it in GitHub Desktop.
Save mcnamee/3fc5b348b37e6657dbc2b99ed7bdb9e0 to your computer and use it in GitHub Desktop.
Install Node / NPM into CloudLinux

How to install Node.js & NPM on CentOS with CloudLinux and CageFS

Add node.js yum repository

yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -

Install node.js and NPM

yum install nodejs

Verify versions

node -v

Make the files accessible for all users

ln -s /usr/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm
cp /usr/bin/node /usr/local/bin/node

Tell CageFS that Node and NPM are allowed

Node:

nano /etc/cagefs/conf.d/node.cfg

With contents:_

[node]
comment=Node
paths=/usr/local/bin/node

NPM:

nano /etc/cagefs/conf.d/npm.cfg

With contents:_

[npm]
comment=NPM
paths=/usr/local/bin/npm

Update CageFS

cagefsctl --force-update
@cloudz
Copy link

cloudz commented Mar 9, 2020

Thanks a lot for this!
Any reason why you stick with Node 6 instead of the current 13 version?

@mcnamee
Copy link
Author

mcnamee commented Mar 12, 2020

@cloudz thanks! Only because node 6 was LTS.

@Sinhcoms-LLP
Copy link

Any way possible to get it to the latest version 14.15

@mcnamee
Copy link
Author

mcnamee commented Jan 12, 2021

Sure thing @Sinhcoms-LLP - have updated.

@garbinmarcelo
Copy link

Thank you, it worked. And with yarn how would the configuration be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment