This article explains how you can install node package on user-level without having root access.
This method was tested on CentOS 7 and Amazon Linux 2. However, this method should work on any Linux version. Please comment below if you are facing any issues.
-
- Create a user for your node application. In our case and its nodeapp1, and switch to the user.
useradd nodeapp1
su - nodeapp1
- Nov install the Node Version Manager (nvm) from the user.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
- Activate nvm with the below commands
~/.nvm/nvm.sh
- Install node with the below command
nvm install node
- Now, let’s check the node version and verify the installation
node -v
- So, now you have installed the latest version of node.js to the user level. v16.6.2 in my case.
[nodeapp1@ip-172-31-19-167 ~]$ node -v v16.6.2
- Create a user for your node application. In our case and its nodeapp1, and switch to the user.