Search code examples
node.jsnpmamazon-ec2nvm

How to properly install nvm/node/npm in AWS EC2 for multiple developers?


Trying to understand how node is supposed to be installed for multiple developers in AWS EC2 as an administrator. (I am also one of the devs).

I have an EC2 server with nginx running on port 80. Should I now go to the webroot and install nvm/node/npm as ec2-user? Or my own user, and then all the other users after? (No one can actually use the ec2-user account except server admins.)

How about other developers who need to use node? I was hoping to install nvm/node/npm for everyone in advance who needs it so that they could use it immediately after getting access to the server, but maybe everyone should install nvm/node/npm themselves?

Or it would be nice if there is a way to install it as ec2-user and then share it with all the users properly/securely? What's the right way to set this up?

(When I ran through this myself as my own user and installed nvm for the first time in EC2 Linux 2 AMI, I noticed that when I switched to another user or root, the "node -v" command didn't work for other accounts - and basically I'm trying to do an install that covers all the users.)


Solution

  • In fact, in AWS EC2, you need only one user and one NodeJS running. I would suggest below set-up for development and deployment.

    1. Let all developers have their dev environment set-up in their local machines.
    2. Let developers check-in their code to Github or a similar repository.
    3. Using a CI/CD pipeline. Integrate the code and build the code and deploy it into EC2.
    4. Instead of EC2, I would recommend using AWS Beanstalk.

    If this makes sense for you, we can elaborate this into a solution and implement it.